In my scheme packrat parser generator I define everything with macros.
Its somewhat simpler in that I don't have to do extra parsing and I get
the benefit of using macro technology to process the Peg.

The generator: https://github.com/kazzmir/Pegs/blob/master/peg.rkt
An example usage:
https://github.com/kazzmir/Pegs/blob/master/peg-tests/calculator.ss

On 11/15/2010 07:32 AM, Alan Post wrote:
> I'm implementing a packrat parser in Scheme.  I'm at the point of
> writing a bootstrap parser in Scheme for PEG, and my bootstrap
> parser is basically working.
>
> I haven't yet decided on the syntax for embedding code in the
> parser.  My only example for doing this is peg/leg:
>
>   http://piumarta.com/software/peg/peg.1.html
>
> which encloses code in {} brackets and permits references to parts
> of the parse tree with <>:
>
>   { action }
>      Curly braces surround actions.  The action is arbitray C  source
>      code  to  be executed at the end of matching.  Any braces within
>      the action must be properly nested.  Any  input  text  that  was
>      matched  before  the action and delimited by angle brackets (see
>      below) is made available within the action as  the  contents  of
>      the character array yytext.  The length of (number of characters
>      in) yytext is available in the variable yyleng.  (These variable
>      names are historical; see lex(1).)
>
>   <  An opening angle bracket always matches (consuming no input) and
>      causes the parser to begin accumulating matched text.  This text
>      will be made available to actions in the variable yytext.
>
>   >  A  closing angle bracket always matches (consuming no input) and
>      causes the parser to stop accumulating text for yytext.
>
> What else is out there?  Is this something reasonably standard or does
> every tool do something different?
>
> -Alan


_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to