Parsing Complex Text Structures
By Ian E. Gorman, June 01, 2000
A pattern language that includes recursive patterns and conditional pattern matching can handle complex text structures without supplementary programming. Ian uses the OmniMark pattern language from OmniMark Technologies to do a job that might otherwise be done with tools like lex and yacc.
Jun00: Programmer's Toolchest
macro INTEGER is digit+ macro-end
define switch function expression
as
do scan #current-input
match INTEGER
match expression '+' expression
match expression '-' expression
match expression '*' expression
match expression '/' expression
match'(' expression ')'
else
return false ; never matched
done
return true ; matched once
Example 5: Pattern function with left recursion.