Why is a custom SyntaxNode subclass not working with parentheses?

43 views
Skip to first unread message

Luc Vu Nang

unread,
Apr 27, 2016, 5:25:39 PM4/27/16
to Treetop Development
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?

Reply all
Reply to author
Forward
0 new messages