[antlr-interest] Is it possible to create a custom "channel"?
Johannes Luber
JALuber at gmx.de
Tue Feb 10 03:24:29 PST 2009
> Hi all, i am new to antlr and i have a conceptual problem:
>
> I want to parse delphi pascal source code.
> In pascal the preprocessor directive is fast the same as a comment:
>
> directive { $R *.dfm }
>
> I want to collect the directives also but i dont't want to have them
> in the rules. It will be impossible to handle this because
> preprocessor directives can appear fast anywhere.
>
> Is there a possibility to create a custom channel and write
>
> COMMENT
> : '{' WS* '$' ( options {greedy=false;} : . )* '}'
> {$channel=CUSTOM;}
If you have a constant named CUSTOM, then the above syntax should work. HIDDEN is simply a predefined integer (probably with the value 100) and the NextToken() method compares the channel property to the used one.
Johannes
--
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
More information about the antlr-interest
mailing list