Reputation: 11030
This is probably simple but I can't see the solution. Antlr v 4.0 tells me:
error(50): C:\Users\Brenden\Dev\proj\WikiParser\antlr\wiki\wikigrammar.g4:27:8:
syntax error: extraneous input '' LINK_BODY '' expecting GT while looking for rule element
This is for the input line:
link: '<' LINK_BODY '>' ;
27:8 refers to the < character. Not sure what is going on. Does < need to be escaped or something? I didn't see that on the wiki. The rest of the file seems to parse OK, there's several lines, the one above this one seems OK, it's terminated with a ; so I don't think anything else is messing this line up. Halp?
Edit: here's LINK_BODY, if it matters:
LINK_BODY: ~[<">]+ ;
Upvotes: 1
Views: 2904
Reputation: 99879
The problem with this grammar started with the use of an improper escape sequence '\'
in a rule which resulted in an unterminated string literal. Since ANTLR 4.0 allows a lexer set (e.g. [a-z]
) or lexer string literal (e.g. 'parser'
) to contain newline characters, every '
character from the point of the mistake to the end of the file was causing it to switch into and out of string literals at all the wrong points.
This behavior has been altered for [the not-yet-released] ANTLR 4.0.1 by disallowing embedded newline characters in both of these tokens.
https://github.com/antlr/antlr4/pull/169
Upvotes: 1