Loading ...
Sorry, an error occurred while loading the content.

A question about Tokens

Expand Messages
  • johnclarke72
    In my Lexer I create a token using my own custom Token Class. This class has some custom methods in it (eg getAttributes - returns a Hashtable). However I
    Message 1 of 2 , Jul 2, 2002
    • 0 Attachment
      In my Lexer I create a token using my own custom Token Class. This
      class has some custom methods in it (eg getAttributes - returns a
      Hashtable). However I don't know how to access these methods from my
      parser.

      How can I access methods from a custom Token Class in my parser ?

      I would be grateful for all advice offered.

      John
    • Terence Parr
      ... label a token reference and then probably have to cast it to your token object then just access like normal method call. rule : label:A
      Message 2 of 2 , Jul 2, 2002
      • 0 Attachment
        On Tuesday, July 2, 2002, at 01:04 PM, johnclarke72 wrote:

        > In my Lexer I create a token using my own custom Token Class. This
        > class has some custom methods in it (eg getAttributes - returns a
        > Hashtable). However I don't know how to access these methods from my
        > parser.
        >
        > How can I access methods from a custom Token Class in my parser ?

        label a token reference and then probably have to cast it to your token
        object then just access like normal method call.

        rule : label:A {((MyToken)label).myMethod();} ;

        Ter
        --
        Co-founder, http://www.jguru.com
        Creator, ANTLR Parser Generator: http://www.antlr.org
      Your message has been successfully submitted and would be delivered to recipients shortly.