On 09/23/14 09:29, Abdelkader Belloundja wrote:
     3) Sum ( Succ X ) ( Y ) = Succ ( X + Y )

The third rule explicitly states a transformation. Could anyone imagine
to carry to same amount of meaning in a context-free grammar rule. And
if so, how !?

I end up with these alternatives :

1) try to stick to the grammar formalism ( the grammar's grammar if you
will  ) and find another interpretation for it, that would closely
ressemble parsing but being synthetical instead of analytical.

2) Incrementally extend the grammar formalism to introduce things like
replacement patterns, and make the algorithm support the enhancements.

I'm not sure if it will be useful to your "encoding computation as PEGs" project, but I've thought a couple times about doing something like replacement patterns as an extension to the PEG formalism. It would be more broadly useful for things like programming language grammars: e.g. a comma-separated list of FOOs as:

    List<FOO> := FOO ( "," FOO )*

which would save you from writing List_Expr and List_Param and who knows how many other rules with the same structure. If you made the parameters dynamic you could even write a PEG for indentation-based block structures (depending on the other features you support), e.g.:

Space<N>  := "\t"{N}
IfExpr<N> := "if" Expr "\n"
             Space<N+1> Expr
             ( Space<N> "else\n"
               Space<N+1> Expr )?



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

Reply via email to