Thx Gavin.

I've already tried adding the $ to the variable name. BTW: I am still 
waiting for complete understanding on this one - some times it matters 
and some times it doesn't.

And isn't it interesting that the invocation of objectPath doesn't have 
the same problem?

____________________
Robert Jozef Vaessen
[EMAIL PROTECTED]
(704) 996-1080




Gavin Lambert wrote:
> At 05:57 9/11/2008, Robert Vaessen wrote:
>> In the grammar (see the attached grammar file) the start rule calls 
>> the booleanExpression rule passing it a string argument. In the 
>> generated class the start() method  invokes a "delegated" rule which 
>> in turn invokes a "fragment" which in turn invokes the 
>> booleanExpression() method (see line 867 in the attached java file) 
>> passing it the string argument which was never passed in by the 
>> start() method???
>
> It's because you've set backtrack=true, so ANTLR has inserted a 
> predicate to perform the lookahead.  Predicates and rule arguments 
> don't really play nicely together, especially if they get hoisted.
>
>> start[String inCdlClassName, String inCdlVariableName] returns 
>> [String code]
>> @init {
>>   linkDefinitions();
>>   pushDefiniton(inCdlClassName);
>>   mCdlVariableName = inCdlVariableName;
>>   CodeBuilder builder = new CodeBuilder();
>> }
>> @after {
>>   $code = builder.toString();
>>   unlinkDefinitions();
>> }
>>   : booleanExpression[inCdlVariableName] { 
>> builder.append($booleanExpression.code); }
>>   | objectPath[builder]
>>   ;
>
> The first thing to try is to use $inCdlVariableName here, so that 
> ANTLR knows you're referring to the parameter.  (You should always do 
> this when referring to a symbol defined in the grammar rather than the 
> code.)
>
> If that doesn't help, then you will probably need to use scopes 
> instead of rule parameters.  Or you could just use mCdlVariableName, 
> since you're saving it anyway.
>
>
>



List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to