[antlr-interest] Default token?

Tangeleno tangeleno at gmail.com
Sun Apr 8 10:27:51 PDT 2012


I'm having a bit of trouble with my lexer, the language I'm working on 
building a parser for does not require strings to be surrounded by 
quotes, for example all of these are valid

string1:Set[This is string 1,this is not string 1] //commas separate 
params, string1:Set takes one, any extras are thrown away
strin1:Set[This is all one string] //I end on the right square bracket
string1:Set["This is string 1,this is all string 1"] // standard string, 
surrounded in quotes to ignore the comma
variable string string1 = This is string 1 //Ends on the new line
variable ComplexType ct = "Param1" 2 "Param3" //Param1 and 3 are strings 
but param2 is an int
echo "This is string 1" "This would be a separate string" //Quoted 
strings are separated by a space or comma
echo This is all one string
echo \t\t I also accept \r\n escape sequences!
SomeCommand0(This is all one string)
SomeCommand1(These,are,all,separate,strings)
SomeCommand2(1,2,3,4,Those are all ints)
SomeCommand3(I can be anywhere!,1,2,3)

I am wondering if there is a way to set a lexer rule to the default 
option if no other lexer rule matches, or any other tips on how to 
handle this.


More information about the antlr-interest mailing list