I forgot to give credit where credit is due. This grammar is from
Aho, A. V., Lam, M. S., Sethi, R., & Ullman, J. D. (2007) Compilers: principles, techniques, & tools (2nd ed.). Boston: Pearson/Addison Wesley. pg. 47, Example 2.5 ---------- Forwarded message ---------- From: The Researcher <[email protected]> Date: Mon, Sep 26, 2011 at 1:51 PM Subject: ANTLRWorks bug: Remove Left Recursion with comments in grammar To: [email protected] grammar Ambiguious001; string : string Plus string | string Minus string | Digit ; Digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ; Minus : '-' ; Plus : '+' ; Remove All Left Recursion or Remove Left Recursion produces grammar Ambiguious001; string : (Digit) (Plus string | Minus string)* ; Digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ; Minus : '-' ; Plus : '+' ; However grammar Ambiguious001; // Parser string : string Plus string | string Minus string | Digit ; // Lexer Digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ; Minus : '-' ; Plus : '+' ; Remove All Left Recursion or Remove Left Recursion produces grammar Ambiguious001; // Parser string : (Digit ;) (Plus string | Minus string)* // Lexer Digit : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' ; Minus : '-' ; Plus : '+' ; It's the first time I have ever had an error wink at me. Eric List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
