[antlr-interest] access to filename

Jim Idle jimi at temporal-wave.com
Sun May 2 16:33:45 PDT 2010


It is a pANTLR3_STRING, not a char *.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Joep Suijs
> Sent: Sunday, May 02, 2010 11:49 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] access to filename
> 
> 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
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address





More information about the antlr-interest mailing list