[antlr-interest] Tree grammar generated for the C runtime reports a syntax error where Java doesn't
Martin Potthast
martin.potthast at uni-weimar.de
Sun Jun 24 07:16:34 PDT 2012
Dear everyone,
I am currently developing a simple grammar for a regex-like language
that involves a tree grammar. When I debug the tree grammar in Java
using ANTLRworks it seems to work fine. However, once I generate C
code, some inputs would fail reporting the syntax error:
-unknown source-(0) : error 1 : Unexpected node, at offset 0,
near DOWN : syntax error...
This might hint at a bug in the C runtime, though I'm not entirely
sure about that. Anyway, since I'm at my wits end about this, I was
wondering whether one of you can help me.
Attached you will find the grammars, their generated C code, and a
text rig. I am using the latest stable release ANTLRworks 1.4.3 and
the latest C runtime libantlr3c-3.4.tar.gz, compiled with the 64 bit
flag.
Clues:
- The offending input is as simple as "[a]" (excluding the quotes).
- The input "[?]" works, the only difference being that the question
mark is a single node in the tree grammar whereas other possibilities
may have an arbitrary number of sub-trees, as indicated by the
wildcards.
- The grammar distinguishes between bracketed expressions that involve
a whitespace and those that don't. Again, the input "[a b]" fails in
C, but not in Java.
I'd be very happy if anyone would help me.
Martin
PS: On a minor note, when regenerating the C code from the grammars
you will notice that RegexWord.c won't compile because one function
contains a line referring to a variable "stream_" that should be
"stream_unit2" in my case. This is a known bug, and after changing the
variable name as indicated, the generated code compiles.
--
Martin Potthast
Bauhaus-Universität Weimar
www.webis.de --- www.netspeak.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grammar.zip
Type: application/zip
Size: 55082 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20120624/c9474b61/attachment.zip
More information about the antlr-interest
mailing list