Closed dmakarov closed 9 years ago
Wait, why did you close this issue?
On Tue, Feb 24, 2015 at 5:21 PM, Dmitri Makarov notifications@github.com wrote:
Closed #149 https://github.com/PhilippeSigaud/Pegged/issues/149.
— Reply to this email directly or view it on GitHub https://github.com/PhilippeSigaud/Pegged/issues/149#event-241027143.
I closed the issue because I realized that the truncated tree for grammars composed of included subgrammars is due to Tree Decimation, which cuts off the nodes coming from external rules. Although it would be nicer to include the nodes from the external rules but not the internal PEGGED nodes, I guess this is not a bug, so I closed the issue. The reason I would want to use grammar composition is to split a larger grammar to submodules, and then have the option of parsing fragments of source code, that are not parsable by the parser generated from the entire composed grammar. However, the latter can be done by calling directly the parsers for specific rules of the entire grammar. And that doesn't have the problem of truncating the tree at the boundary of nodes coming from the external rules.
Perhaps, this is by design, but it's confusing to use grammar composition. For example:
produces the output
I would expect that every
Expr.Primary
node would have a child likeTerm.Identifier
orTerm.FloatLiteral
. The nodesExpr.Primary
have no children. Is this how grammar composition designed to work, i.e. no subtrees for any rules included from other grammars? It seems like a serious limitation.