[antlr-interest] Stuck
Ryan Daum
ryan at darksleep.com
Mon Aug 20 11:19:18 PDT 2007
Thanks John... However, when I remove the 'fragment' qualifier, it
doesn't help :-(
Ryan
On Mon, 2007-20-08 at 14:07 -0400, John B. Brodie wrote:
> Ryan Daum asked (in part):
> >Hi all,
>
> Greetings!
>
> >I'm writing a fairly simple grammar for the following protocol:
> >
> >http://www.belfry.com/fuzzball/trebuchet/mcp.html
> >
> >However, I'm stuck on a problem at the lexer level that I can't seem to
> >solve. I believe it's my final issue before I have a working parser.
> >
> >Basically, I have a number of rules which can match a combination of
> >characters:
> >
> > fragment
> > LINE : (LINE_CHAR)* EOF;
> > IDENT : ALPHA (ALPHA|DIGIT|'-' ~(SPACE | COLON |
> > OTHER_CHAR))* ;
>
> ...snipped...
>
> >This is all fine, individually they work well. However, in the rule:
> >
> > messageContinue
> > : STAR SPACE datatag SPACE IDENT COLON SPACE LINE
> > -> ^(MESSAGE_CONTINUE datatag LINE);
> >
> >Working against the following line:
> >
> > * 9b76 text: This is some sample text.
> >
> >I always get a MismatchedTokenException because the parser seems to want
> >to turn everything after SPACE into an IDENT, rather than a line. The
> >intention of "LINE" is just to collect all input after the SPACE in a
> >messageContinue; I do not want the rest of the lexer's rules to apply at
> >all.
> >
>
> I have not really looked too much at your grammar...
>
> But right off I see that LINE is a fragment. This means that the
> Parser will never see a LINE token.
>
> Could that be your problem?
>
> HTH
> -jbb
>
More information about the antlr-interest
mailing list