Newbe question

53 views
Skip to first unread message

Jay Janarthanan

unread,
May 30, 2016, 12:39:30 PM5/30/16
to Eto.Parse
Been playing with Eto.Parse this weekend, I love Fluent style of coding. I got the following code. I assume the order on the line I marked in Red matters ? if I change it then the parsing does not work 

Jay




Curtis Wensley

unread,
Jun 2, 2016, 3:45:51 PM6/2/16
to Eto.Parse
Hey Jay,

This is because of the recursive descent behaviour of Eto.Parse, which is stateless. It is different from other parsers which use a state machine to determine the possible states at any given position.  

For Eto.Parse, if you put wordParser first, it will match and won't try any of the other options.  Thus the 'or' (or AlternativeParser) will have found the matching alternate without any knowledge that the following character won't match.

So, when designing grammar with alternates especially, you need to put the alternate that has the 'longest' match first.

Hope this helps!
Curtis.
Reply all
Reply to author
Forward
0 new messages