[antlr-interest] Another Comments question
Ric Klaren
klaren at cs.utwente.nl
Mon Jul 28 03:03:06 PDT 2003
Hi,
On Mon, Jul 28, 2003 at 10:53:27AM +1000, Tom Davies wrote:
> (Context is just the place I keep my symbol table and all the functions
> which create my target code)
>
> I also have a rule:
> pStatement: ("CL"^ | "DEF"^ | "DD"^ | "ZCL"^ | "SCL"^ | "XCL"^)
> EQUALS! IDENTIFIER (FILESUFFIX)? (COMMA! "NEW")? c:SEP!
> ;
>
> I'd like to say:
> pStatement: a:("CL"^ | "DEF"^ | "DD"^ | "ZCL"^ | "SCL"^ | "XCL"^)
> EQUALS! IDENTIFIER (FILESUFFIX)? (COMMA! "NEW")? b:SEP!
> { Context.get().setBeforeComments(##,a,b); }
> ;
You might be able to get away with
pStatement { Token a; }: ("CL"^ | "DEF"^ | "DD"^ | "ZCL"^ | "SCL"^ | "XCL"^)
{ a = ##.getToken(); }
EQUALS! IDENTIFIER (FILESUFFIX)? (COMMA! "NEW")? b:SEP!
{ Context.get().setBeforeComments(##,a,b); }
Else you have to label the alternatives and check them for null (or
nullAST) check the generated code to be sure.
Cheers,
Ric
--
-----+++++*****************************************************+++++++++-------
---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722 ----
-----+++++*****************************************************+++++++++-------
There are 10 kinds of people - those that understand binary and
those that don't. --- Unknown
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list