[antlr-interest] Methods and dynamically scoped variables

Christian Andersson dt05ca4 at student.lth.se
Tue Oct 30 02:55:06 PDT 2007


>
> On Oct 29, 2007, at 10:21 AM, Christian Andersson wrote:
>
>> Hi all!
>>
>> I have a lot of java code in my grammar that uses a lot of dynamically
>> scoped attributes. Quite often the code look the same using the same
>> attributes and so on, this gives me a lot of problem maintaining
>> the code,
>> having to change the same value in many places and the code also gets
>> unnecessary large.
>>
>> I really would like to change these long code sequences with
>> methods instead.
>> I tried to put @member between @init @after, though no error was
>> reported
>> in ANTLRWorks no code was generated to java.
>
> Hi. @name {action} works anywhere and is sent to the target to do
> what it wants (per target). No errors are currently generated.
>
>> Can you only use @members on top of the file using no dynamically
>> scoped
>> attributes?
>
> Yes.
>
> Ter
>

Thanks for your answer!

I tried to put @name{action} in my tree grammar file but no code
is generated. The only place where I can put the "name" action without the
generator complaining is between
the rule name and the contents of that rule(where the @init and @after is).

How do you invoke the @name{actions} from the tree grammar rules?

Is it possible to split up the grammar and the java actions in the tree
grammar file into several files to improve overview (the file consists of
3000 lines of java and tree grammar rules mixed and is still growing, the
overview is really messy)?


Thanks for your help!
Br Christian





More information about the antlr-interest mailing list