[antlr-interest] insert after tree?

Geoff hendrey geoff_hendrey at yahoo.com
Sun Jan 6 10:56:56 PST 2008


It's the first case you mention below. 



More specifically, I need to recognize SQL "LIKE" expression trees from
within a SQL statement and add the text "ESCAPE '~'" after the LIKE
expression's tree. I have this in my grammar file.



likeExpression

    :(concatenationExpression 'LIKE' concatenationExpression) ->^('LIKE' concatenationExpression+ ESCAPE)     ;



I added the imaginary ESCAPE token, but I have not had any luck in my
Java trying to replace the imaginary escape token with the real text
"ESCAPE '~'". If only I could add a *real* token through my rewrite
rule above , I would be in business.



On PAge 176 of Terence's book it shows how to construct an imaginary
token with from a real token, but I don't have a real token to use (as
far as I can tell), which means I can't use the TokeRewriteStream with the imaginary token, as far as I can tell.


 
-geoff





----- Original Message ----
From: Harald M. Müller <harald_m_mueller at gmx.de>
To: Geoff hendrey <geoff_hendrey at yahoo.com>; antlr-interest at antlr.org
Sent: Sunday, January 6, 2008 9:04:04 AM
Subject: RE: [antlr-interest] insert after tree?




 
DIV {
MARGIN:0px;}



Sorry - I don't understand your question: 


- You have an AST?

- you want to output it again as text?

- but after some sub-AST of it, you want to have written 
some additional text?

 

or

 

- You have an AST

- you want to insert a node behind a certain 
sub-AST

so that later tree parsers/walkers will see that additional 
node

 

Is it one of these two - or something 
differently?

 

Sorry for being a little bit slow ...

Regards

Harald



  
  
  From: antlr-interest-bounces at antlr.org 
  [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Geoff 
  hendrey
Sent: Sunday, January 06, 2008 9:22 AM
To: 
  antlr-interest at antlr.org
Subject: [antlr-interest] insert after 
  tree?



  

  From 
  my Java program, I want to insert text after a *tree* not after a 
  token.

I guess I am looking for a "TreeRewriteStream" as opposed to a 
  TokenRewriteStream. 

As a workaroud I tried creating an imaginary token 
  in my grammar file and using it to identify the rightmost side of a tree. Like 
  this:

a 'func' a ->^('func' a+ IMAGINARY)

But then as I found 
  out, the IMAGINARY Token doesn't seem to work with 
  TokenRewriteStream.insertAfter.

Can anybody advise on how I can insert 
  text immediately after a particular tree? (The text is static so perhaps there 
  is a way to do it from the grammar file...)

  





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080106/a8469459/attachment-0001.html 


More information about the antlr-interest mailing list