Question

I have defined a syntax using treetop and most of the values parse fine, but some look like

Response+Isupport1 offset=0, "...orted by this server" (host,space1,space2,nickname,space3):

... and ...

...
SyntaxNode+Isupport0 offset=52, "WATCH=128 " (token,space):
    SyntaxNode+Token0 offset=52, "WATCH=128" (parameter,equals,value):
    ...

What does the SyntaxNode+[Node] mean? How can I fix it to work correctly? Because now, these nodes have the SyntaxNode class, not the Token class (which makes them generic and doesn't fit my needs).

As far as I can see, defining (token space)+ is what caused this (no idea why).

Was it helpful?

Solution

Your question is very incomplete, which is probably why it didn't get answered, but as the person who wrote the inspect implementation that produces the above display, I can probably shed light. Treetop creates SyntaxNodes (or an instance of a different class, if you request that), and then augments them with mixin modules that contain your code. You can get multiple modules mixed in to a single node, because a rule that calls only one sub-rule can add a new module to the node returned by that sub-rule. Every type you include a code block starting with {, you get a new module. The parenthesised list of interesting methods at the end of each inspect line have come from these mixins.

However, as to why your grammar doesn't work, you'd have to show it to us with your input and expected parse result to get an answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top