Why does my lexer throw an unexpected char exception in the middle of my comment or string rule containing a wildcard?

Terence Parr

Most likely you need a charVocabulary option to specify the set of characters you expect. The wildcard or ~ operator make no sense unless you bound the set of possible characters. For example,

SL_COMMENT
options {
        paraphrase="SL_COMMENT";
}
        : "//" (~'
')* '
'
                { $setType(Token.SKIP()); newline(); }
        ;
Won't work because ~' ' is only the '/' char. Add something like:
charVocabulary = '3'..'377';
See options documentation for more info.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact