Balanced parenthesis cannot be expressed using regular expression which means you cannot recognize it using lexer. You need a push down automata which means you need a parser to recognize it. Try doing it using parser rules.
Cheers, Indhu From: [email protected] [mailto:[email protected]] On Behalf Of Espák Miklós Sent: Tuesday, October 13, 2009 10:04 PM To: [email protected] Subject: [antlr-interest] accepting nested code blocks Hi, I want to create a lexer rule accepting nested code blocks. I tried out the example of the Definitive ANTLR Reference (Section 4.3), but it does not work. It accepts only such inputs which do not contain any character other than curly braces. Moreover, one closing brace is enough. The error is the following: MismatchedTokenException: line 1:1 mismatched input UNKNOW expecting 125 The original code of the book: fragment CODE[boolean stripCurlies]: '{' ( CODE[stripCurlies] | ~('{' |'}' ) )* '}' { if ( stripCurlies ) { setText(getText().substring(1, getText().length())); } } ; The simplified version of the rule results the same: fragment Block: '{' ( Block | ~('{'|'}') )* '}'; I use ANTLR 3.2. Does anybody have an idea, how to get around this? Thanks, Miklos --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
