[antlr-interest] Re: Getting correct line information
braden_mcdaniel
braden at endoframe.com
Wed Feb 13 14:24:58 PST 2002
--- In antlr-interest at y..., mzukowski at b... wrote:
>
>
> > -----Original Message-----
> > From: braden_mcdaniel [mailto:braden at e...]
> > Sent: Wednesday, February 13, 2002 8:42 AM
> > To: antlr-interest at y...
> > Subject: [antlr-interest] Re: Getting correct line information
> >
> >
> > --- In antlr-interest at y..., mzukowski at b... wrote:
> > > Sounds like you need to tweak your scanner so that when it creates
> > > Tokens it fills in the line info properly.
> >
> > Actually, I am doing that. I instantiate a CommonToken and call
> > setLine on it. I have used CommonToken::getLine inside the scanner to
> > confirm that the value in the Token is correct. This value doesn't
> > appear to have any effect on the line number returned in parser error
> > messages.
>
> Then something is wrong with the reportError() method either in your
parser
> or inherited by it.
>
> > > If you use an ANTLR scanner then you simply need to call newline()
> > > whenever you want to increment the line count.
> >
> > Meaning I could derive from CharScanner and just override nextToken as
> > I do now, but call newline instead of (in addition to?) setting
> > this information directly on the Token?
>
> No, that won't behave any differently. I had assumed that the Token's
> getLine() wasn't working properly, which should be how the parser
gets it's
> line number to report. But if you are doing that part right then
maybe it's
> a bug in the code generator or base classes. Fire up a debugger and
find
> out.
Silly me. I just needed to be using the constructor of
SemanticException that takes a line number.
Braden
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list