On 3/11/12 3:02 AM, Philippe Sigaud wrote:
There is an operator to drop unnecessary nodes (':').
Good.
Apart from that, a Pegged grammar is a self-contained entity: it automatically cuts nodes coming from other grammars, to simplify the tree (it keeps the matcheds substrings, of course). I plan to code different type of grammars, to play with the way the deal with nodes coming from outside rules and grammar composition.
Not getting this, but picture me with an intense look and nodding.
As for the root, the PEG rule is that the first rule in the grammar is the root. But currently, I deliberately made my grammars unsealed, in that the user can call any rule inside the grammar to begin parsing: mixin(grammar(" A<- B C B<- ... C<- ")); A.parse("some input"); // standard way to do it, the parse tree will be rooted on an 'A' node. B.parse("some input"); // also possible, the parse tree will be rooted on a 'B' node.
That sounds cool, but how do you say that in the construct Expression <- Term "+" Term the "+" should become the root? Andrei