Why is a custom SyntaxNode subclass not working with parentheses?

44 views Asked by At

I have a treetop grammar like below:

grammar Addme

  rule AddExpr
    Num '+' Num
  end

  rule Num
    [0-9]+ <ExprNumber>
  end

end

This is working when I parse the expression:

g = AddmeParser.new
t = g.parse("1234+56789")

. . . there is a syntax node that matches "1234" with type ExprNumber. But, if I add parentheses to the rule like this:

rule Num
    ([0-9]+) <ExprNumber>
end

It will not match the class ExprNumber. Why would this happen?

1

There are 1 answers

0
cliffordheath On

The node has already been created inside the parentheses. A module can be mixed in, but not a class.