[antlr-interest] Fwd: imaginary nodes

Thomas Jackson thomas.jackson.iii at gmail.com
Mon Oct 8 14:41:22 PDT 2007


Forgot to forward to group.....

---------- Forwarded message ----------
From: Thomas Jackson <thomas.jackson.iii at gmail.com>
Date: Oct 8, 2007 5:17 PM
Subject: Re: [antlr-interest] imaginary nodes
To: Mark Volkmann <r.mark.volkmann at gmail.com>

grammar T;

options { output=AST; language=Java; }

tokens {
  PARAGRAPH;
  SENTENCE;
  NOUN;
  VERB;
  ADJECTIVE;
  THIS="this";
  IS="is";
  A="a";
  BAD="bad";
  EXAMPLE="example";
}

parse : THIS IS A BAD EXAMPLE -> ^( PARAGRAPH ^(SENTENCE ^(NOUN EXAMPLE)
^(ADJECTIVE BAD) ^(VERB IS)))
         ;
Hope this helps...

Thanks
Thomas


On 10/8/07, Mark Volkmann <r.mark.volkmann at gmail.com> wrote:
>
> In "The Definitive ANTLR Reference" chapter 7, page 166 of my printed
> copy, in the discussion about adding imaginary nodes to an AST it says
> "The imaginary token must be defined elsewhere in a grammar or in the
> tokens section." I can't seem to find an example of where this is done
> in the book though. Can someone give me an example of the syntax to
> define an imaginary node in a grammar?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>



-- 
Thomas Jackson

-- 
Thomas Jackson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071008/e225461d/attachment.html 


More information about the antlr-interest mailing list