[antlr-interest] 3.0b5: help with parse puzzle

Terence Parr parrt at cs.usfca.edu
Thu Nov 23 21:41:28 PST 2006


hi. ~'\n' won't do you much good in the parser. ;)

That error is saying it found EOF.

Ter
On Nov 23, 2006, at 9:11 PM, Paul Shaffer wrote:

> Can you suggest a fix for this?
>
> g file:
>
> grammar s1;
> options {
>     language = CSharp;
>     filter=true;
> }
> program: string_def+  ;
>
> string_def:  ID '=' (~'\n')+ '\n'     { Console.Out.WriteLine 
> ("found string_def"); }   ;
>
> ID  :   ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*  ;
>
> WS  :   (' '|'\n'|'\r')+ {$channel=HIDDEN;}  ;
>
>
> Input line, it can contain a '\' followed by a 'n' anywhere. Line  
> is terminated in 0D 0A.
>
> testline = "This is a test line I am working on "with difficulty".\n 
> \nSometimes we meet some troublesome characters.\n\nTime's a wastin'."
>
>
> Runtime error message:
>
> [string_def]: line 0:-1 mismatched token: [@0,0:0='<no text>',<-1>, 
> 0:-1]; expecting type '\n'
>
> Can someone interpret what this line says? I don't know how to read  
> it.
>
> If I turn off filtering, I also get a "no viable alt line" error on  
> every . \ and " in the input.
>
>
>



More information about the antlr-interest mailing list