[antlr-interest] Confusing, hopefully-final, problems
Sam Barnett-Cormack
s.barnett-cormack at lancaster.ac.uk
Mon Mar 2 03:48:14 PST 2009
Sam Barnett-Cormack wrote:
> Hey all,
>
> With Gavin's generous help, I'm down to one error and a couple of
> warnings, which is nice.
>
> In the attached grammar, I haven't fixed the lexer issues Gavin
> identified yet, as I'm focused on the parser for the moment.
>
> The error is on line 473, as are two of the warnings. I can't say as I
> can figure out what it's getting at all, but I'm probably just being dumb.
>
> The rule is
>
> extensionAndException : '...' exceptionSpec? ;
>
> and exceptionSpec is:
>
> exceptionSpec : ('!' exceptionIdentification)? ;
>
> exceptionIdentification : signedNumber | definedValue | type ':' value ;
>
> The error and warnings are:
>
> warning(200): workspace/asn.1-parse/grammars/ASN_1.g:346:82: Decision
> can match input such as "'('" using multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
> warning(200): workspace/asn.1-parse/grammars/ASN_1.g:473:31: Decision
> can match input such as "'}'" using multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
> warning(200): workspace/asn.1-parse/grammars/ASN_1.g:473:31: Decision
> can match input such as "','" using multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
> error(201): workspace/asn.1-parse/grammars/ASN_1.g:473:31: The following
> alternatives can never be matched: 2
>
> My best guess is that the problem comes from "type" in the
> exceptionIdentification rule, but then I'd expect the error to be there,
> and not in extensionAndException.
No, Sam, it's because a rule is referenced as optional, and that rule
can match nothing as well, so there's no point it being optional...
So I'm now down to a warning about
type : ((typeWithConstraint)=>typeWithConstraint | builtinType |
referencedType) constraint* ;
And a load of parser warnings and errors that it wasn't bothering to
generate before... *sigh*
Sam
More information about the antlr-interest
mailing list