Hello,<br><br>I&#39;ve just started learning and playing with ANTLR.<br>I am writing a subset of the JavaScript grammar (as the examples at <a href="http://antlr.org">antlr.org</a> don&#39;t work for me).<br>In ANTLRWorks, when I use the interpreter, the second rule generates two errors with messages:<br>
<br>first node -&gt; &quot;FailedPredicateException(sourceElements, {can&#39;t deal with predicates yet}?)&quot;<br>second node -&gt; &quot;FailedPredicateException(sourceElements, {synpred3_JavaScript}?)&quot;<br><br>(parse tree with the error nodes can be found in the attachment)<br>
<br>However, if I use the debugger, the parsing is successful.<br>Why is this so?<br><br>My grammar is the following (also in attachment):<br><br><div style="margin-left: 40px; font-family: courier new,monospace;">grammar JavaScript;<br>
<br>options {<br>    backtrack=true;<br>    memoize=true;<br>}<br><br>program<br>    : sourceElements EOF<br>    ;<br>    <br>sourceElements<br>    : LT* ( sourceElement LT* )*<br>    ;<br>    <br>sourceElement<br>    : functionDeclaration<br>
    | statement<br>    ;<br>    <br>functionDeclaration<br>    : &#39;function&#39; LT* Identifier LT* formalParameterList LT* functionBody<br>    ;<br>    <br>formalParameterList<br>    : &#39;(&#39; LT* ( Identifier ( LT* &#39;,&#39; LT* Identifier )* )? LT* &#39;)&#39;<br>
    ;<br><br>functionBody<br>    : &#39;{&#39; sourceElements &#39;}&#39;<br>    ;<br><br>statement<br>    : emptyStatement<br>    | blockStatement<br>    ;<br>    <br>emptyStatement<br>    : &#39;;&#39;<br>    ;<br>    <br>
blockStatement<br>    : &#39;{&#39; LT* statementList? LT* &#39;}&#39;<br>    ;<br>    <br>statementList<br>    : statement ( LT* statement )*<br>    ;<br><br><br>Identifier<br>    : IdentifierStart IdentifierPart*<br>    ;<br>
    <br>fragment IdentifierStart<br>    : UnicodeLetter<br>    | &#39;$&#39;<br>    | &#39;_&#39;<br>        ;<br>        <br>fragment IdentifierPart<br>    : IdentifierStart<br>    | UnicodeDigit<br>    ;<br>    <br>fragment UnicodeLetter<br>
    : &#39;a&#39;..&#39;z&#39; | &#39;A&#39;..&#39;Z&#39;<br>    ;<br><br>fragment UnicodeDigit<br>    : &#39;0&#39;..&#39;9&#39;<br>    ;<br><br>LT<br>    : &#39;\n&#39; | &#39;\r&#39;<br>    ;<br>    <br>MultilineComment<br>
    : &#39;/*&#39; (options { greedy=false; } : .)* &#39;*/&#39; { $channel=HIDDEN; }<br>    ;<br><br>LineComment<br>    : &#39;//&#39; ~(LT)* { $channel=HIDDEN; }<br>    ;<br>    <br>WhiteSpace <br>    :  ( &#39; &#39; | &#39;\t&#39; | &#39;\v&#39; | &#39;\f&#39; )  { $channel=HIDDEN; }<br>
    ;<br><br><br></div><br>Thank you,<br>regards<br><br><br>-- <br>Filipe David Manana,<br><a href="mailto:fdmanana@ieee.org">fdmanana@ieee.org</a><br>PGP key - <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0xC569452B">http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0xC569452B</a><br>
<br>&quot;Reasonable men adapt themselves to the world.<br> Unreasonable men adapt the world to themselves.<br> That&#39;s why all progress depends on unreasonable men.&quot;<br><br>