<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18854"></HEAD>
<BODY>
<DIV><FONT size=2 face=Arial>
<DIV><FONT size=2 face=Arial><SPAN class=281110005-15122009>I'm trying to build
an AST that has extraneous tokens removed. But whether or not I use a
rewrite rule, ANTLRworks always shows me an AST with every token in it. Is
that normal ANTLRworks behavior, or am I missing some
directive? </SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial><SPAN
class=281110005-15122009></SPAN></FONT> </DIV>
<DIV><FONT size=2 face=Arial><SPAN class=281110005-15122009>Below is a snippet
of the grammar...</SPAN></FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face="Courier New">options <BR>{ <BR> language =
CSharp2; // CSharp2 targets .Net 2.0 (as opposed to CSharp which targets
.Net 1.1<SPAN class=281110005-15122009>)</SPAN><BR> output =
AST;<BR>}</FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><FONT size=2 face="Courier New">prog : stat+
;</FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV><SPAN class=281110005-15122009><FONT size=2 face="Courier New">// The
following statements produce the same AST display in ANTLRworks...
</FONT></SPAN></DIV>
<DIV><SPAN class=281110005-15122009><FONT size=2
face="Courier New"></FONT></SPAN> </DIV>
<DIV><FONT face="Courier New"><FONT size=2>stat :
'showInt' '(' <SPAN class=281110005-15122009> </SPAN>STRING
',' <SPAN class=281110005-15122009> </SPAN>expr ')'<SPAN
class=281110005-15122009> // All tokens expected to be in the
AST</SPAN></FONT></FONT></DIV>
<DIV><FONT face="Courier New"><FONT size=2><SPAN
class=281110005-15122009></SPAN></FONT></FONT> </DIV>
<DIV><FONT face="Courier New"><FONT size=2><SPAN
class=281110005-15122009></SPAN>stat :
'showInt' '(' <SPAN class=281110005-15122009> </SPAN>STRING
',' <SPAN class=281110005-15122009> </SPAN>expr ')' <SPAN
class=281110005-15122009> </SPAN>-> <SPAN class=281110005-15122009>
</SPAN>^( 'showInt' STRING expr )<SPAN class=281110005-15122009> //
Token suppression via rewrite</SPAN><SPAN
class=281110005-15122009> </SPAN></FONT></FONT></DIV>
<DIV><FONT size=2 face="Courier New"></FONT> </DIV>
<DIV>
<DIV><FONT size=2><FONT face="Courier New">stat :
'showInt' '('<SPAN class=281110005-15122009>!</SPAN> STRING ','<SPAN
class=281110005-15122009>!</SPAN> expr ')'<SPAN class=281110005-15122009>! //
Another way to suppress tokens</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=281110005-15122009></SPAN></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN
class=281110005-15122009></SPAN></FONT></FONT> </DIV>
<DIV><FONT size=2><FONT face="Courier New"><SPAN class=281110005-15122009>Input
is: showInt ( "an int: " , (67 * 98) mod 7
)</SPAN></FONT></FONT></DIV></DIV></FONT></DIV></BODY></HTML>