[antlr-interest] Re: How to set filename in parser
shmuel siegel
antlr at shmuelhome.mine.nu
Fri Jul 15 05:27:25 PDT 2005
> I'm wondering now, if we are only interested in line directives, whether
> we could pass them to the parser as a token or tokens. Since they cannot
> split statements perhaps they could be treated as just another statement
> and processed appropriately?
>
> Any comments?
>
> David Wigg
>
Why can't #line directives split statements? Why couldn't the source be
x= 3+
#include "commonExpression.h"
+4;
Anyway, what I ended up doing was
1) introduce a local variable in the lexer for saving the filename. (the
one from inputState is inaccessable to the parser.)
2) save a reference to the lexer in the parser
3) overiding the parser's getFilename method to reference the saved
filename.
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.15/49 - Release Date: 7/14/2005
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.15/49 - Release Date: 7/14/2005
More information about the antlr-interest
mailing list