[antlr-interest] Bug? Invalid Java code generated

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Fri Mar 6 14:23:23 PST 2009


Terence Parr wrote:
> 
> On Mar 6, 2009, at 2:02 PM, Sam Barnett-Cormack wrote:
> 
>> Terence Parr wrote:
>>> Hi Guys,quikly scanning...$text means text for entire rule; if 
>>> hoisted out of rule it makes no sense. sem predicates should only use 
>>> functions of input.LT(i) if they get hoisted.
>>
>> So can I replace
>>
>> objIdComponents options{backtrack=true;}
>>  : nameForm {isStandardOIDName($text)}?
>>  | numberForm
>>  | nameAndNumberForm
>>  | definedValue
>>  ;
>>
>> with
>>
>> objIdComponents options{backtrack=true;}
>>  : nameForm {isStandardOIDName($nameForm.text)}?
>>  | numberForm
>>  | nameAndNumberForm
>>  | definedValue
>>  ;
>>
> 
> Well, that won't behoisted into any decisions.
> 
> you need
> 
> : {isStandardOIDName(input.LT(1).getText())}? nameForm

Okay... it seems like things involving $text *do* get hoisted, just they 
end up as errors in the Java... but in any case, I'll do that once I can 
get at my code again. This may involve transplanting a hard drive...

Sam

-- 
Sam Barnett-Cormack


More information about the antlr-interest mailing list