Hi again, On Wed, Aug 6, 2008 at 06:34, Orlando Hill <[EMAIL PROTECTED]> wrote: > You're right. Arnar Birgisson emailed me...
When I read this I realized I had made the mistake of not pressing "reply all" which I meant to do :) Here's my email to Orlando, Hi Orlando, Thanks, this sounds very interesting. I have a couple of comments.. On Tue, Aug 5, 2008 at 21:18, Orlando Hill <[EMAIL PROTECTED]> wrote: > I made a few small changes to make grammars easier for me to read. > > The first was to make the '*', '+' and '?' operators prefix like the > '&' and '!' operators are. I found that my mind would "backtrack" when > reading grammars written in postfix. This is subjective of course, but I prefer the postfixing of *, + and ? as a reminder of the relation to regular expressions. > I also changed the '/' to '|' but, that could just be personal preference. Again, subjective, but I prefer / over | to emphasize the "priority-ness" of the alternatives, i.e. alternatives to the left have higher precedence. Due to its traditional use, | gives an immediate hint of non-determinism. I believe this was one of Bryan's reasons for choosing / in the first place. > Each non-terminal rule corresponds to a node type in the AST. I > considered various ways to specify what should be included in the > trees but, I realized the main thing I wanted to do was just remove > one or two expressions. > > So, the way I get rid of horizontal noise in the AST is to prefix an > expression with ':'. > > e.g. > Here, the '=' character is useless information since, when processing > the tree, it is already implicit that a '=' character was read. > > Assignment <- Variable :'=' Expression > > When a non-terminal is never needed it can be specified with '<:' > instead of '<-'. > > Ws <: *[ \t\n\r] I like these. > If it turns out to be really needed, it would be easy to have options > to specify that, if a given rule only has one child result, that child > should take its place. That could either be handled within the parser > or as an automatically generated tree post-processor. > > e.g. When only one Num is matched, have that be returned from Prod. > > Prod <- Num *([*/] Ws Num) If you do this, it might be helpful to have some syntax to say "always construct a node with this type, even if it has only one child". Something of the sort Prod <= Num *([*/] Ws Num) cheers, Arnar _______________________________________________ PEG mailing list PEG@lists.csail.mit.edu https://lists.csail.mit.edu/mailman/listinfo/peg