[antlr-interest] How to use LT and LA in predicates?

Johannes Luber jaluber at gmx.de
Fri Apr 20 15:53:43 PDT 2007


Hello,

in the beta book Terence wrote, that one has to define the isTypeName()
method in this rule somewhere else:

type_id
   :  {isTypeName(input.LT(1).getText())}? ID
   ;

Problem is, that LT seems to return only an integer after Eclipse syntax
analyzer. So how do I get the text? In another example

primary
  :  {isType(input.LT(1))}? ID '(' expr ')' //ctor-styletypecast
  ;

the getText() method doesn't seem needed. How does that work? Are there
any tutorials explaining the use of those methods in more detail? The
beta book is lacking there. Another thing I miss is a description how
actions like @header work and how many there are of them.

Best regards,
Johannes Luber


More information about the antlr-interest mailing list