dlang-community / Pegged

A Parsing Expression Grammar (PEG) module, using the D programming language.
533 stars 66 forks source link

Calling rule keeps all the leafs without a match #207

Open Temtaime opened 8 years ago

Temtaime commented 8 years ago

For example if i call certain rule from my grammar, it returns a parsetree with all the internal « or / and / etc » nodes. But when i call the grammar itself there's no such nodes. Also it seems there's no flags for this behavior. How can i get rid of such nodes ?

veelo commented 8 years ago

Maybe this is caused by the call to decimateTree() in opCall() in the generated parser?

PhilippeSigaud commented 8 years ago

Hi,

On Thu, Mar 31, 2016 at 10:10 PM, Temtaime notifications@github.com wrote:

For example if i call certain rule from my grammar, it returns a parsetree with all the internal « or / and / etc » nodes. But when i call all the grammar there's no such nodes.

That's explained in the docs :

https://github.com/PhilippeSigaud/Pegged/wiki/Using-a-Grammar#calling-a-rule

Calling a rule directly is more 'low-level' than calling the grammar.

Also it seems there's no flags for this behavior. How can i get rid of such nodes ?

Use 'decimateTree()'. See the previous link, and also:

https://github.com/PhilippeSigaud/Pegged/wiki/Tree-Decimation#tree-decimation