[antlr-interest] Meaning of error message: expecting EOA, found 'Q'

Kay Roepke kroepke at classdump.org
Tue Jul 10 17:34:26 PDT 2007


Hi Don!

On Jul 11, 2007, at 1:54 AM, Don Maier wrote:

> /* A quote-bracketed sequence of non-quote characters, though  
> permitting embedded
> * escaped quotes in the forma of '\"'.  The content is the  
> character string
> * between the quotes, which may contain leading and trailing  
> spaces, tabs,
> * carriage returns, or newlines.
> */
> /*
> QUOTED_CONTENT
> 	: Q (options {greedy=false;} : (~(Q|'\\'Q)))* Q
> 	;

Did you actually mean to write:

QUOTED_CONTENT
	: Q (options {greedy=false;} : (~Q|'\\'Q) )* Q
	;

The inverted set ~(Q|'\\'Q) confuses the hell out the ANTLR's parser.  
It expects the
alternative Q|'\\'Q to end after the '\\' but sees another Q. That's  
illegal syntax and
thus it's failing. Of course the error message *is* terribly cryptic  
at the moment...
EOA means end-of-alternative.

Anyway, I guess what you really wanted is the 'inverted set of Q OR a  
sequence of '\\' and Q'.

> ------------------------------
>
> Is it possible that this somehow affects the tree parser, but not  
> the basic parser?

No, that's just ANTLR's error message misleading you. The AST in the  
error just points to
ANTLR's internal treeparser (of the grammar) throwing up. Nothing you  
did with trees.


HTH,
-k
-- 
Kay Röpke
http://classdump.org/






More information about the antlr-interest mailing list