[antlr-interest] access to filename
Joep Suijs
jsuijs at gmail.com
Sun May 2 11:49:13 PDT 2010
Hi guys,
For error reporting, I need access to the origination of a token when
I walk through the tree after it is parsed. This works okay for line
number and position on the line, but fails for the filename. A piece
of the code used:
ANTLR3_UINT32 TokenType = child->getType(child);
CIndent(Level);
printf("%s (%d, %s from ",child->toString(child)->chars,
TokenType, jalParserTokenNames[TokenType]);
ANTLR3_INPUT_STREAM *is = Token->input;
printf("input stream %x,",is);
// printf("input stream %d,",is->fileName);
printf("Line %d:%d)",Token->getLine(Token),
Token->getCharPositionInLine(Token));
The input stream print shows a non-zero pointer, but uncommenting the
last line triggers an exception. The next line prints the line &
postion as expected.
What am I doing wrong?
Joep
More information about the antlr-interest
mailing list