I found a solution to both the variable hoisting and scope consistency
problems related to prediction with predicates. The solution is clean
but non-trivial, so I'm putting together some detailed documentation on
my rationale, the approach I used, and the explicit preconditions that,
when met, guarantee a grammar will not run into hoisting or consistency
problems in the generated code. An explicit initialization section for
attribute scopes is necessary for it to work.

 

For the C# port, I'm going to implement this as @scopeinit for now and
see how it turns out.

 

Sam

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Jim Idle
Sent: Thursday, January 22, 2009 12:27 PM
Cc: [email protected]
Subject: Re: [antlr-dev] @init for global scopes?

 

I am not sure why this is of any advantage? What limitation are you
trying to get around? Choosing where to initialize a global scope or
something? This change will generate work for all other targets and the
syntactic change potentially generates confusion, especially if it is
left at @init. In C, I have some macros such as SCOPE_TOP(sname) for
action code - perhaps I implemented these to get around some limitation
that you are proposing a fix for? I no longer remember ;-)

Jim

_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to