[antlr-interest] recovering from incomplete syntax

Michiel Vermandel Michiel_Vermandel at axi.be
Wed Apr 12 23:50:20 PDT 2006


I guess your WS rule then does not include the \r and \n tokens anymore.
Else you've got two lexer rules for the same tokens, right.

But if the \r \n tokens are only read by the EOL lexer rule, and since in 
(forms) plsql you can continue a statement over multiple lines, I should 
have to add an optional EOL token after every token of almost every 
statement...

That is what I mentioned in my original mail.

Thanks, Michiel






Sam Barnett-Cormack <sdb at geekworld.co.uk> 
12/04/2006 20:28

To
Michiel Vermandel <Michiel_Vermandel at axi.be>
cc

Subject
Re: [antlr-interest] recovering from incomplete syntax






Michiel Vermandel wrote:
> But here I get to a second problem. I have a definition of bindVariable
> in my grammar like this:
> <pre>COLON! IDENTIFIER (DOT IDENTIFIER)? </pre>
> Since The lexer skips any space, tab or CRLF characters (usual WS
> implementation), The parser sees the following line of code:
> <tt>lName := :MYBLOCK.lName := UPPER(lName);</tt>
> So, in order to detect the real problem, I need to take the
> enter-character into account. This means that I can not set the WS lexer
> rule to type Token.SKIP. But that again will require a lot of changes
> into my parser grammer (to accept the WS characters) and probably will
> cause a lot of overhead.

This part is simple; I recently did my first ANTLR grammars, and needed
to be aware of line break, but not of other whitespace. So, I made one
WS rule that does TOKEN.SKIP, and then an EOL rule that matches \r, \n,
and \r\n (with k>1) which increments the line number, but doesn't set
TOKEN.SKIP. I then use EOL as a 'statement terminator' in the grammar.

Sam

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060413/9b053dda/attachment.html


More information about the antlr-interest mailing list