[antlr-interest] Struggling with RewriteEmptyStreamException

Johannes Luber jaluber at gmx.de
Wed Jul 16 11:40:13 PDT 2008


craig at palantir.co.za schrieb:
> Hi,
> 
> I have scaled back to the following simple grammar.
> I am trying to parse 'declare namespace ns1=...'
> 
> I cannot even get that simple part to work. I am not sure what I am doing wrong
> in the rewrite rule. The C# target is throwing a RewriteEmptyStreamException
> (token DECLARE) when I make a new token, and rewrite to a new empty token it
> complains about the $i as the symbol and so on.
> 
> What am I missing?
> Version 3.1b1.

Please rebuild the runtime - unfortunately the one included is slightly 
stale.

Johannes

> 
> grammar XQuery;
> 
> options {
>    language=CSharp2;
>    output=AST; }
> tokens {
>   DECLARE='declare';
>   NAMESPACE='namespace';
>   ROOT='//';
>   SEPARATOR='/';
> }
> 
> // parser rules.
> query: declaration+ ;
> declaration: DECLARE NAMESPACE i=IDENTIFIER '=' l=LITERAL ';' -> ^(DECLARE $i
> $l) ;
> 
> // token section.
> IDENTIFIER:			('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ;
> INTEGER:			'0'..'9'+ ;
> NEWLINE:			'\r'? '\n' ;
> COMPARATOR:			'>'|'<'|'>='|'<='|'=';
> LITERAL:			'"' LITERAL_CHAR* '"';
> WS:					(' '|'\t'|'\n'|'\r')+ { $channel = HIDDEN; } ;
> fragment
> LITERAL_CHAR:		~('\"'|'\\') ;
> 
> 
> 
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
> 
> 



More information about the antlr-interest mailing list