[antlr-interest] Token position 0, -1
Ale Strooisma
alestrooisma at gmx.net
Fri Jul 6 04:04:47 PDT 2012
No, I had the issue with for example identifiers.
The actual situation where I encountered it is the following: if my
context-checker encounters a binary expression, it checks if both
children nodes are of the same type. If they are not, an exception is
thrown using the coordinates of the token of the first node for
indicating the position of the error.
I suppose that such a child node can never contain an imaginary token.
However, I will check if I made a dramatic programming error such that I
accidentally pass the wrong nodes to the function checking this.
Ale
On 07/06/2012 12:58 PM, Bart Kiers wrote:
> On Fri, Jul 6, 2012 at 11:47 AM, Ale Strooisma <alestrooisma at gmx.net
> <mailto:alestrooisma at gmx.net>> wrote:
>
> Hello,
>
> if I try to get the position of a token in the file with getLine and
> getCharPositionInLine, many of my tokens give the coördinates 0, -1,
> which obviously is wrong. Why is this the case, and how can I fix it?
>
>
> Hi Ale,
>
> Are the tokens that return -1 imaginary tokens? These (imaginary)
> tokens don't have a real position in the input after all.
>
> Regards,
>
> Bart.
More information about the antlr-interest
mailing list