[antlr-interest] getting the correct line # from an exception
Michael Brade
brade at informatik.uni-muenchen.de
Sat Mar 4 03:35:39 PST 2006
Hi,
On Saturday 04 March 2006 04:53, Vladimir Sutskever wrote:
> I think this should work:
> [...]
> *NEWLINE*
> : '\t'
> | '\n'
> | '\r'
> {
> $setType(Token.SKIP);
> newline();
> }
> ;
No, it most probably won't... You don't want to increment the line number on a
tab (\t). And the action you put at the end is only called for \r because the
parentheses are missing. Here's what I'm using:
protected
EOL : ( options { generateAmbigWarnings = false; }
: "\r\n"
| '\r'
| '\n' ) { newline(); } ;
I have no Token.SKIP in there because I use this protected rule in two other
rules that already set the Token.SKIP type.
Cheers,
--
Michael Brade; KDE Developer, Student of Computer Science
|-mail: echo brade !#|tr -d "c oh"|s\e\d 's/e/\@/2;s/$/.org/;s/bra/k/2'
°--web: http://www.kde.org/people/michaelb.html
KDE 4: Beyond Your Expectations
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20060304/7fff49e0/attachment-0001.bin
More information about the antlr-interest
mailing list