When the runtime was changed to use the latest version of StringTemplate,
there were changes made which broke tree generation by tree parsers – I am
aware that this is the case but have had no time to correct it.



I find git to be terrible (have to be frank) and I really don’t want to use
it – however I am grateful for your work and perhaps you can co-ordinate
with Ter to push/pull that work in to the main code line?



Jim



*From:* antlr-dev-boun...@antlr.org [mailto:antlr-dev-boun...@antlr.org] *On
Behalf Of *Stephen Gaito
*Sent:* Saturday, April 07, 2012 3:39 PM
*To:* antlr-dev@antlr.org
*Subject:* [antlr-dev] Inconsistencies between ANTLR 3.4 C.stg and ANTLR
gitHub C.stg versions



Hello,

My ultimate goal is to build a LaTeXCreole parser/filter to embed in PHP
(Drupal) so that I can more comfortably talk about mathematics....

To do this I have chosen to use the ANTLR project and its C runtime (many
thanks to both Terence and Jim).

To keep the complexity down I have chosen to manipulate AST trees in a
number of passes using tree grammars which generate trees.

My current grammar fragments work in Java, but alas the exact same grammar
files (with the obvious changes from Java to C), complain of StringTemplate
problems when building the tree grammars.

I suspect the C runtime has not been tested with many tree grammars which
generate their own trees.

SO... to help ensure the ANTLR C runtime can build tree grammars which
generate trees, *I have forked the antlr/antlr3 project on GitHub
(stephengaito/antlr3) and begun building my grammars using the most recent
3.4.1-snapshot version.*

Unfortunately, my parser and lexer grammars no longer compile in the C
versions (when using the v3.4.1-snapshot tools).... some investigation
later and *I find that in at least three places in the
tool/src/main/resources/org/antlr/codegen/templates/C/C.stg file, there are
differences between the same file in the released v3.4 complete jar and the
gitHub version.*  None of these differences are recorded in the gitHub
version from before the v3.4 was tagged released on  July 18, 2011 until
today (April 7, 2012). (I am unsure where the v3.4 released version of this
file has come from).

SO... *I have made two mini-branches on my fork of antlr3 to fix each of
the lexer and parser differences.  I have fixed both problems by
reinstating the text from the as released complete tar.*

My lexer and parser files now both compile with both the as released v3.4
ANTLR tools and the v3.4.1-snapshot ANTLR tools taken from gitHub (today).

(My tree grammar generation of trees investigation will continue).

*If you are interested I would be happy to post a bug/issue report* on
antlr/antlr3 issues system (it seems in-appropriate for me to post this bug
on the antlr/antlr4 version since it is not for new code).

*Alternatively I would be happy to issue pull requests.
*
Regards,
Stephen Gaito

PS: the changes to
tool/src/main/resources/org/antlr/codegen/templates/C/C.stg are as follows:

------------------------

@@ -2132,7 +2132,9 @@ else

 <if(LEXER)>

     LRECOVER();

 <else>

+<! use following code to make it recover inline;

     RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_<ruleName><elementIndex>);

+!>

 <endif>

     goto rule<ruleDescriptor.name>Ex;

 }<\n>

@@ -2143,7 +2145,10 @@ CONSTRUCTEX();

 EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;

 EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;

 <if(PARSER)>

+EXCEPTION->expectingSet = NULL;

+<! use following code to make it recover inline;

 EXCEPTION->expectingSet = &FOLLOW_set_in_<ruleName><elementIndex>;

+!>

 <endif>

 >>



@@ -2510,7 +2515,7 @@ static const ANTLR3_INT32
dfa<dfa.decisionNumber>_T<i0>[] =

  */

 static const ANTLR3_INT32 * const dfa<dfa.decisionNumber>_transitions[] =

 {

-    <dfa.transitionEdgeTables:{xref|dfa<dfa.decisionNumber>_T<xref>};
separator=", ", wrap="\n", null="_empty">

+    <dfa.transitionEdgeTables:{xref|dfa<dfa.decisionNumber>_T<xref>};
separator=", ", wrap="\n", null="NULL">

 };



 <if(dfa.specialStateSTs)>
_______________________________________________
antlr-dev mailing list
antlr-dev@antlr.org
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to