<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16788" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I'm curious why labels do not work with AST 
rewrites in a rule such as this:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>myRule : 'KEYWORD' '=' (INTEGER | FLOATNUMBER | 
HEXNUMBER | identifier | QUOTED_STRING)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>per the Definitive Guide to ANTLR, it *seems* like 
this would work:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>myRule : 'KEYWORD' '=' keyvalue=(INTEGER | 
FLOATNUMBER | HEXNUMBER | identifier | QUOTED_STRING) -&gt; ^(KEYWORD 
$keyvalue)</FONT><FONT face=Arial size=2></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>and, the above is certainly more intuitive (no?) 
than what does work:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>myRule : 'KEYWORD' '=' (INTEGER | FLOATNUMBER | 
HEXNUMBER | identifier | QUOTED_STRING) -&gt; ^(KEYWORD INTEGER* FLOATNUMBER* 
HEXNUMBER* identifier* QUOTED_STRING*)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>The keyvalue example throws a <FONT 
face="Times New Roman" size=3>RewriteEmptyStreamException because the generated 
code adds a null node to a RewriteRuleTokenStream, which causes a .NextNode() 
call to bomb out because there's no tokens in the stream at the time that call 
is made.&nbsp; </FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I'm rather puzzled why that's the 
case.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Question: would the label format work if I follow 
some guidelines in subrules???&nbsp; </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Ben</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>