<span class="Apple-style-span" style="border-collapse: collapse; ">Hi&nbsp;<span style="border-collapse: collapse; white-space: pre-wrap; ">Gavin Lamber:</span><div><span style="border-collapse: collapse; white-space: pre-wrap; ">     Thanks for your reply.</span></div>
<div><span style="border-collapse: collapse; white-space: pre-wrap; ">     I tried the lexer rule you gave me. But following error comes out:</span></div><div><span style="border-collapse: collapse; white-space: pre-wrap; "><br>
</span></div><div><span style="border-collapse: collapse; white-space: pre-wrap; "> Alternative 155: after matching input such as &#39;F&#39;&#39;U&#39;&#39;N&#39;&#39;C&#39;&#39;T&#39;&#39;I&#39;&#39;O&#39;&#39;N&#39;&#39;F&#39;&#39;U&#39;&#39;N&#39;&#39;C&#39;&#39;T&#39;&#39;I&#39;&#39;O&#39;&#39;N&#39;&#39;F&#39;&#39;U&#39;&#39;N&#39;&#39;C&#39;&#39;T&#39;&#39;I&#39;&#39;O&#39;&#39;N&#39;&#39;E&#39;&#39;N&#39;&#39;D&#39;&#39;_&#39;&#39;F&#39;&#39;U&#39;&#39;N&#39;&#39;C&#39;&#39;T&#39;&#39;I&#39;&#39;O&#39;&#39;N&#39;{&#39;0&#39;..&#39;9&#39;, &#39;A&#39;..&#39;Z&#39;, &#39;_&#39;, &#39;a&#39;..&#39;z&#39;}&#39;F&#39;&#39;U&#39;&#39;N&#39;&#39;C&#39;&#39;T&#39;&#39;I&#39;&#39;O&#39;&#39;N&#39;&#39;E&#39;&#39;N&#39;&#39;D&#39;&#39;_&#39;&#39;F&#39;&#39;U&#39;&#39;N&#39;&#39;C&#39;&#39;T&#39;&#39;I&#39;&#39;O&#39;&#39;N&#39;{&#39;0&#39;..&#39;9&#39;, &#39;A&#39;..&#39;Z&#39;, &#39;_&#39;, &#39;a&#39;..&#39;z&#39;}&#39;F&#39;&#39;U&#39;&#39;N&#39;&#39;C&#39;&#39;T&#39;&#39;I&#39;&#39;O&#39;{&#39;\u0000&#39;..&#39;/&#39;, &#39;:&#39;..&#39;@&#39;, &#39;N&#39;, &#39;[&#39;..&#39;^&#39;, &#39;`&#39;, &#39;{&#39;..&#39;\uFFFF&#39;} decision cannot predict what comes next due to recursion overflow to FUNCTION_DECL from FUNCTION_DECL</span></div>
</span><br><div class="gmail_quote">On Tue, Jan 13, 2009 at 7:11 PM, Gavin Lambert <span dir="ltr">&lt;<a href="mailto:antlr@mirality.co.nz">antlr@mirality.co.nz</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">At 22:10 13/01/2009, chain one wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I want to recognize a function definition and skip it before passing tokens to the parser.<br>
The function definition starts with &quot;FUNCTION&quot; ,ends with &quot;END_FUNCTION&quot;.<br>
</blockquote></div>
[...]<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
FUNCTION_DECL<br>
: &#39;FUNCTION&#39;<br>
{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $channel=HIDDEN;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp; &nbsp; ( options {greedy=false;} : . )* &nbsp;FUNCTION_DECL ( options {greedy=false;} : . )* &nbsp;&#39;END_FUNCTION&#39; SEMI<br>
;<br>
</blockquote>
<br></div>
You might need to be more explicit about it:<div class="Ih2E3d"><br>
<br>
FUNCTION_DECL<br>
 &nbsp;: &#39;FUNCTION&#39; { $channel = HIDDEN; }<br></div>
 &nbsp; &nbsp;(FUNCTION_DECL | ~&#39;E&#39; | &#39;E&#39; ~&#39;N&#39; | &#39;EN&#39; ~&#39;D&#39; | &#39;END&#39; ~&#39;_&#39; |<br>
 &nbsp; &nbsp; &#39;END_&#39; ~&#39;F&#39; | &#39;END_F&#39; ~&#39;U&#39; | &#39;END_FU&#39; ~&#39;N&#39; | &#39;END_FUN&#39; ~&#39;C&#39; |<br>
 &nbsp; &nbsp; &#39;END_FUNC&#39; ~&#39;T&#39; | &#39;END_FUNCT&#39; ~&#39;I&#39; | &#39;END_FUNCTI&#39; ~&#39;O&#39; |<br>
 &nbsp; &nbsp; &#39;END_FUNCTIO&#39; ~&#39;N&#39; | &#39;END_FUNCTION&#39; ~SEMI)*<br>
 &nbsp; &nbsp;&#39;END_FUNCTION&#39; SEMI<br>
 &nbsp;;<br>
<br>
(This assumes that whitespace isn&#39;t permitted between END_FUNCTION and the semicolon.)<br>
<br>
Also, if you&#39;re wanting to skip over large chunks of your input, then you might want to investigate filtering lexers.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This also could not work : ( :<br>
<br>
fragment<br>
FUNCTION:<br>
&#39;FUNCTION&#39;<br>
;<br>
</blockquote></div>
[...]<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
FUNCTION_DECL<br>
:FUNCTION<br>
{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SKIP();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; &nbsp; &nbsp; ( ~(FUNCTION|END_FUNCTION)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; |<br>
 &nbsp; &nbsp; &nbsp; &nbsp; FUNCTION_DECL<br>
 &nbsp; &nbsp; &nbsp; &nbsp; )* &nbsp;END_FUNCTION SEMI<br>
;<br>
</blockquote>
<br></div>
The reason why that doesn&#39;t work is that ~ can only take the inverse of sets, and sets in a lexer rule are alternatives of individual characters. &nbsp;FUNCTION and END_FUNCTION are not sets, they&#39;re sequences, so it&#39;s illegal to use ~ on them.<br>

<br>
</blockquote></div><br>