[antlr-interest] ANTLR 3.1.2 bug in tree grammars? - RewriteEmptyStreamException
"Paul Bouché (NSN)"
paul.bouche at nsn.com
Tue Feb 24 02:57:55 PST 2009
Hi,
I just upgraded to ANTLR v3.1.2 from 3.0. What worked before does not
work anymore.... :-( I looked through the changes list, but could not
find anything related.
We first create an AST and then parse it with a tree grammar. The syntax
is a list key = value pairs, where a structure can be built using curly
brackets. A structure is again a list of key-value pairs, i.e.
struct = { a = 3, b = 4 }
also
struct = { }
was allowed which created an empty sub structure.
This is broken now. I get the exception:
Exception in thread "main"
org.antlr.runtime.tree.RewriteEmptyStreamException: rule properties
at
org.antlr.runtime.tree.RewriteRuleElementStream._next(RewriteRuleElementStream.java:158)
at
org.antlr.runtime.tree.RewriteRuleElementStream.nextTree(RewriteRuleElementStream.java:145)
...
I have no clue whatsoever what this means. Well obviously somehow the
parser tries to rewrite an empty stream. Well before 3.1.2, in 3.0 this
worked fine without errors. Now it does not work. Something must have
changed or is it a bug?
The grammar for parsing the above syntax is basically as follows:
start
:
propertynode EOF
;
propertynode
:
properties -> ^( TYPE PROPERTYNODE ) properties
;
properties
:
( property ( ',' property )* )? ','? -> property*
;
property
:
name '=' value -> ^( PROPERTY name cast?
attributes? value )
;
value
:
( plain | '{' propertynode '}' ) -> plain?
list? propertynode?
;
As you can see rule value calls propertynode which allows substructures.
If the rule properties does match an empty obviously a stream is not
instanciated as it was before in 3.0 hence the exception. Can you tell
me how I need to modify the grammar to make it work in 3.1.2?
Thanks a bunch!
Paul
--
Paul Bouché
Voice: +49 30 590080-1284
Nokia Siemens Networks GmbH & Co. KG, An den Treptowers 1, 12435 Berlin, Germany
Sitz der Gesellschaft: München / Registered office: Munich
Registergericht: München / Commercial registry: Munich, HRA 88537
WEEE-Reg.-Nr.: DE 52984304
Persönlich haftende Gesellschafterin / General Partner: Nokia Siemens Networks Management GmbH
Geschäftsleitung / Board of Directors: Lydia Sommer, Olaf Horsthemke
Vorsitzender des Aufsichtsrats / Chairman of supervisory board: Lauri Kivinen
Sitz der Gesellschaft: München / Registered office: Munich
Registergericht: München / Commercial registry: Munich, HRB 163416
More information about the antlr-interest
mailing list