[antlr-interest] Labels broken?

Johannes Luber jaluber at gmx.de
Wed Feb 11 23:09:00 PST 2009


Gary R. Van Sickle schrieb:
>> >From what I can tell from page 170 of the book, this should result in
> "^(DECL_SPECS <<list of decl specs>>)":
> 
> declaration_specifiers
> 	: ds+=(   storage_class_specifier
> 		  |   type_specifier
>       |   type_qualifier
>       | function_specifier
>       | extended_decl_specs
>     )+ -> ^(DECL_SPECS $ds+)
> 	;
> 
> With "ANTLR Parser Generator  Version 3.1.2-2008-10-21", it doesn't, in fact
> it results in a broken parser (not the tree parser, there isn't one yet).  I
> instead get a bunch of this sort of error:
> 
> ./test/testprog1/test.c(2)  : error 8 : Unexpected token, at offset 12
>     near [Index: 6 (Start: 8980854-Stop: 8980870) ='THIS_IS_A_TYPEDEF',
> type<39> Line: 2 LinePos:12]
>      : syntax not recognized...
> 
> Doing "ds=" results in the same problem.  Am I misunderstanding something,
> or is this breakage?
> 
It's a long standing bug that labels don't work with parentheses. Either
put the label in front of every alternative or put the contents of the
parentheses into an extra rule so you can get rid of the parentheses.

Johannes


More information about the antlr-interest mailing list