[antlr-interest] Why stream name can't be printed out when error occurs(ANTLR C)?

Jim Idle jimi at temporal-wave.com
Tue May 24 09:46:03 PDT 2011


There can be multiple streams and you should reallty be using the file
name in the filestream, which you get from the token. Originally, we could
not get back to the filestream from the token and now we can, hence the
example error code uses what was available when I wrote it and also avoids
(at the time) dealing with stringstreams that might not have a name
(though now they always do of course).

Jim



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mu Qiao
> Sent: Tuesday, May 24, 2011 7:36 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Why stream name can't be printed out when
> error occurs(ANTLR C)?
>
> I set the fileName for ANTLR3_INPUT_STREAM and the file name can be
> printed out when error occurs. But when the tree parser is involved,
> the name can't be always printed out (print unknown-source instead
> sometimes).
>
> I checked the implementation of antlr3baserecognizer.c and I find the
> name is decided by tnode->token. However, as we have
> tns->istream->streamName, why not use that attribute? This will ensure
> the name can be printed out no matter what kind of the current token it
> is.
>
> --
> Best wishes,
> Mu Qiao
> GnuPG fingerprint: 92B1 B0C4 8D14 F8C4 EFA5  3ACC 30B3 0DE4 17B1 57E9
>
> 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