It should be pretty simple. I am working on lexical grammar using ANTLR and want to limit the maximum length of variable identifiers to 30 characters. I tried to accomplish this with this line (after the usual regular expression - except for the syntax "thing"):
ID : ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'){0,29} {System.out.println("IDENTIFIER FOUND.");} ;
There are no errors in the code generation, but compilation failed due to a line in the generated code, which was simple:
0.29
Obviously, antlr takes a section of text between the brackets and places it in the acceptance status area along with the print line. I searched the ANTLR site and I did not find an example or link to an equivalent expression. What should be the syntax of this expression?
user1634761
source share