Next | Higher-Order Parsing | 42 |
Lately my big project has been a constraint-oriented drawing system called linogram
The input language contains constructions like:
constraints { ... }
And:
define square extends rectangle { ... }
So I use an even higher-level parser constructor:
sub labeled_block { my ($header, $item, $separator) = @_; $separator = lookfor(";") unless defined $separator; conc($header, lookfor("{"), list_of($item, $separator), lookfor("}")); }
And define really complex parsers with it:
$constraint_block = labeled_block(L("CONSTRAINTS"), $constraint);
$definition = labeled_block($Definition_header, $declaration);
Next | Copyright © 2007 M. J. Dominus |