Jim Idle wrote: > The interpreter is just a quick testing device and is easily fooled by > grammar rules, use the debugger and not the interpreter and all will be fine.
Yes, but what Kyle pointed out seems like an obvious bug in the interpreter in a case that it is supposed to be able to handle. Either bugs like this should be fixed, or there is no point in having the interpreter and all and it should be removed, with its functionality being replaced by the debugger. >> -----Original Message----- >> From: [email protected] [mailto:antlr-interest- >> [email protected]] On Behalf Of Kyle Ferrio >> Sent: Friday, January 01, 2010 11:11 AM >> To: [email protected] >> Subject: [antlr-interest] Repost: ANTLRworks: Why do these rules behave >> differently in the embedded interpreter? >> [...] >> That leaves us with the following rule, for which the interpreter runs >> without error on our test input: >> >> expr >> : multExpr ( ( '+' multExpr | '-' multExpr ) )* >> ; >> >> [This is potentially ambiguous. Does a token bind more tightly to >> another token, or to the binary operator '|' for alternatives? Yes, >> we know the official ANTLR answer, but I'm questioning my >> understanding of the specific implementation embodied in ANTLRworks. >> See next rule.] >> >> So I figured [maybe wrongly?] I was right about actions causing >> problems. But wait. Let's dig deeper. This second rule >> >> expr >> : multExpr ( ( '+' multExpr ) | ( '-' multExpr ) )* >> ; >> >> works in the interpreter as expected for the first alternative (used >> for 3+1) but produces a MisMatchedTokenException for the second >> alternative (used for 3-1). >> >> And better yet, this third rule >> >> expr >> : multExpr ( ( ( '+' multExpr ) | ( '-' multExpr ) ) )* >> ; >> >> works great in the interpreter for both 3+1 and 3-1, just like the >> first rule does. -- David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
signature.asc
Description: OpenPGP digital signature
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
