[antlr-interest] (newbie) mismatched error

Gavin Lambert antlr at mirality.co.nz
Mon Jul 16 13:09:20 PDT 2007


At 07:22 17/07/2007, ali azimi wrote:
>Could you please tell me what I am doing wrong that the system 
>emits the following error messages when my test file tries to 
>recognise the input:  system s; endsystem;

While I don't think I can give you a direct answer, I have noticed 
some odd things in the grammar you posted:

>line 1:7 mismatched character 's' expecting 't'
>line 1:10 no viable alternative at input 'endsystem'
>The grammar is as following:
>
>textualSystemDefinition
>             :packageReferenceClause*('system' systemName end 
> entityInSystem* 'endsystem'(systemName)?end->^(PACKREF 
> packageReferenceClause* 'system' systemName end entityInSystem+ 
> 'endsystem'systemName?end)

Well, you haven't told us what 'systemName' is defined as, and 
that's where the error is occurring...

>word    :(alphaNumeric|'.')*alphaNumeric(alphaNumeric|'.')*
>             ;

So a word could be '..............6........'?  That seems like an 
odd definition...

>alphanumeric
>             :Uppercase|National|Lowercase|Decimaldigit
>             ;
>
>Decimaldigit
>             :'0'..'9'
>             ;
>
>National
>             :'#'|'@'|'"'|'$'|'['|']'|'{'|'}'|'^'|'~'
>             ;
>
>Lowercase
>             :'a'..'z'
>             ;
>Uppercase
>             :'A'..'Z'+

Why is the Uppercase rule a set of multiple characters, while none 
of the other rules are?  Seems a bit inconsistent...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070717/e41bd62c/attachment.html 


More information about the antlr-interest mailing list