[TransWarp] fmtparse - recursive grammar

Phillip J. Eby pje at telecommunity.com
Fri Jun 13 16:22:23 EDT 2003


At 04:11 PM 6/13/03 -0400, Phillip J. Eby wrote:
>Consider this:
>
>class AndOr(model.Type):
>     mdl_syntax = fmtparse.Alternatives('and','or')
>
>class Query(model.Type):
>     class operator(model.Feature):
>         referencedType = AndOr
>     class subqueries(model.Sequence):
>         referencedType = 'Query'

I forgot to include:

          separator = ','

here, to show that the 'subqueries' items are ','-separated.


>     mdl_syntax = Sequence(operator, '(', subqueries, ')')

Also, based on your examples of the syntax, I assume this actually needs to 
be something like:

     class simple(model.Feature):
          referencedType = model.String

     mdl_syntax = Alternatives(
         Sequence(operator, '(', subqueries, ')'),
         simple
     )

(That is, a query's syntax is either  'op(subqry,...)' or a simple 
identifier).

As you can see, the overall framework becomes rather more expressive as a 
rule-annotated AST domain model.




More information about the PEAK mailing list