<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>

<META content="MSHTML 6.00.6000.16788" name=GENERATOR></HEAD>
<BODY>
<DIV><EM><SPAN class=853354317-01012009>On </SPAN>Tue Dec 30<SPAN 
class=853354317-01012009>, 2008, at 10:56 PST, Terrence Parr 
wrote</SPAN></EM></DIV>
<DIV><FONT face="Lucida Console"><FONT size=2><FONT face=Arial><SPAN 
class=853354317-01012009>&gt; </SPAN>Hi. you'll have to call the lexer methods 
directly on the generated&nbsp;&nbsp;<BR><SPAN class=853354317-01012009>&gt; 
</SPAN>lexer not using delegates I think</FONT></FONT></FONT></DIV>
<DIV><FONT face="Lucida Console"><FONT size=2><FONT 
face=Arial></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face="Lucida Console"><SPAN class=853354317-01012009><FONT face=Arial 
size=2>As it turns out, I can insert the delegates myself as a 
workaround</FONT></SPAN></FONT><FONT face="Lucida Console"><SPAN 
class=853354317-01012009><FONT face=Arial size=2>.</FONT></SPAN></FONT></DIV>
<DIV><FONT face="Lucida Console"><SPAN 
class=853354317-01012009></SPAN>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><I>--------- begin C.g 
---------<BR></I></FONT><FONT face=Arial><I>grammar C ;<BR></I></FONT><FONT 
face=Arial><I>import L, P2 ;</I></FONT></FONT></DIV>
<DIV><BR><EM><FONT face=Arial size=2>@lexer::members {<BR>&nbsp; public final 
void mLETTER() throws RecognitionException { gL.mLETTER(); 
}<BR>}</FONT></EM></DIV>
<DIV><BR><FONT face=Arial><FONT size=2><I>stuff : ( letters spaces )+ 
;<BR></I></FONT></FONT><FONT size=2><I><FONT face=Arial>--------- end&nbsp;<SPAN 
class=853354317-01012009>C.g </SPAN>------------</FONT></I></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial></FONT></FONT>&nbsp;</DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial size=2>This is a pain for a 
large grammar, but it will only have to be done once&nbsp;(assuming all&nbsp;my 
new development is happening at the top level, and there are no lexicon updates 
coming in at the bottom levels). I can find the name of the delegates, e.g., 
"gL", in my CLexer.java file. I can find the method signature lines, e.g. 
"<EM>public final void mLETTER() throws RecognitionException</EM>", in my 
C_L.java file.&nbsp;Of course, if I override a lexer rule, I have to remove the 
delegator, but if I forget, I get a reminder from the&nbsp;Java 
compiler:</FONT></SPAN></DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial size=2>------------- begin 
Java compile error message ----------</FONT></SPAN></DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial size=2>CLexer.java:52: 
mLETTER() is already defined in CLexer<BR>&nbsp;&nbsp;&nbsp; public final void 
mLETTER() throws RecognitionException 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
^<BR>CLexer.java:14: cannot find symbol<BR>symbol&nbsp; : method 
mLETTER()<BR>location: class C_L<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public final 
void mLETTER() throws RecognitionException { gL.mLETTER(); }</FONT></SPAN></DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial size=2>------------ end 
Java compile error message ----------</FONT></SPAN></DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial size=2>This should work. 
But I hope the next release automates the delegation for the 
lexer.</FONT></SPAN></DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial 
size=2>George</FONT></SPAN></DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=853354317-01012009><FONT face=Arial 
size=2>--------------------------- begin original message 
----------------------------------------</FONT></SPAN></DIV>
<DIV></FONT><FONT face=Arial size=2>Hi. you'll have to call the lexer methods 
directly on the generated&nbsp; <BR>lexer not using delegates I 
think<BR>Ter<BR>On Dec 30, 2008, at 7:16 AM, George S. Cowan 
wrote:<BR><BR>&gt;<I> The generated lexer for composite grammars does not 
generate the&nbsp; <BR></I>&gt;<I> delegation methods for lexer rules in the 
topmost grammar. This is&nbsp; <BR></I>&gt;<I> only a problem if one is directly 
calling the lexer methods, for&nbsp; <BR></I>&gt;<I> instance, in unit testing 
and, in particular, testing lexer rules in&nbsp; <BR></I>&gt;<I> 
gUnit.<BR></I>&gt;<I><BR></I>&gt;<I> Here is the example grammar from the 
Composite Grammar page (<A 
href="http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars">http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars</A> 
<BR></I>&gt;<I> ) with slight modifications so it will 
work:<BR></I>&gt;<I><BR></I>&gt;<I> -------------------- begin L.g 
--------------<BR></I>&gt;<I> lexer grammar L ;<BR></I>&gt;<I> LETTER : 'a'..'z' 
;<BR></I>&gt;<I> ---- begin P1.g&nbsp; ---<BR></I>&gt;<I> parser grammar P1 
;<BR></I>&gt;<I> letter : LETTER ;<BR></I>&gt;<I> spaces : ' '+ ;<BR></I>&gt;<I> 
--- begin P2.g ---<BR></I>&gt;<I> parser grammar P2 ;<BR></I>&gt;<I> import P1 
;<BR></I>&gt;<I> letters : letter+ ;<BR></I>&gt;<I> --------- begin C.g 
---------<BR></I>&gt;<I> grammar C ;<BR></I>&gt;<I> import L, P2 
;<BR></I>&gt;<I> stuff : ( letters spaces )+ ;<BR></I>&gt;<I> --------- end 
grammar files ------------<BR></I>&gt;<I><BR></I>&gt;<I> Here is the gUnit test 
file and the exception:<BR></I>&gt;<I> ------ CTest.testsuite 
-----<BR></I>&gt;<I> gunit C;<BR></I>&gt;<I> LETTER<BR></I>&gt;<I> : 
"a"&nbsp;&nbsp; OK<BR></I>&gt;<I>&nbsp;&nbsp; "A"&nbsp;&nbsp; 
FAIL<BR></I>&gt;<I> ------------------------ runtime exception&nbsp; 
<BR></I>&gt;<I> -------------------------------<BR></I>&gt;<I> 
java.lang.NoSuchMethodException: 
CLexer.mLETTER()<BR></I>&gt;<I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
at java.lang.Class.getMethod(Unknown 
Source)<BR></I>&gt;<I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at 
org.antlr.gunit.gUnitExecuter.runLexer(gUnitExecuter.java: <BR></I>&gt;<I> 
211)<BR></I>&gt;<I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at&nbsp; 
<BR></I>&gt;<I> 
org.antlr.gunit.gUnitExecuter.runCorrectParser(gUnitExecuter.java:131)<BR></I>&gt;<I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
at&nbsp; <BR></I>&gt;<I> 
org.antlr.gunit.gUnitExecuter.executeTests(gUnitExecuter.java:149)<BR></I>&gt;<I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
at org.antlr.gunit.gUnitExecuter.execTest(gUnitExecuter.java: <BR></I>&gt;<I> 
97)<BR></I>&gt;<I>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at 
org.antlr.gunit.Interp.main(Interp.java:62)<BR></I>&gt;<I> 
------------------------ END&nbsp; <BR></I>&gt;<I> 
--------------------------------------------------<BR></I>&gt;<I><BR></DIV></I></FONT></BODY></HTML>