[antlr-interest] No lexer rules matched

alan brown listbrownie at gmail.com
Thu Mar 6 17:51:14 PST 2008


I've split my lexer and parser up and am using tokenVocab to tell my parser
where to find the lexer rules.  As follows:

grammar FParser;

options {tokenVocab=FLexer; backtrack=true; k=15;}

@synpredgate { true }


@header {
package parse.grammar;

import parse.beans.*;
}

@members {
    F builder = new FBuilder();
}


f_hh_file        : ftp_hh+ ;

f_hh            : {System.out.println("WIBBLE");}
            introduction betting_rounds


However, when I run the parser I get the following odd output on the
console:

[17:43:53] warning(105): /src/parse/grammar/FParser.g:124:15: no lexer rule
corresponding to token: NUMBER
[17:43:53] warning(105): /src/parse/grammar/FParser.g:126:26: no lexer rule
corresponding to token: NL
[17:43:53] warning(105): /src/parse/grammar/FParser.g:101:38: no lexer rule
corresponding to token: NL
[17:43:53] warning(105): /src/parse/grammar/FParser.g:77:33: no lexer rule
corresponding to token: L_PAREN
[17:43:53] warning(105): /src/parse/grammar/FParser.g:122:54: no lexer rule
corresponding to token: R_PAREN

which clearly bodes ill.  Also, further bafflement ensues when I see that
the output is reading in every other character and skipping the ones in
between.

line 1:0 mismatched character 'F' expecting ','
line 1:2 mismatched character 'l' expecting ','
line 1:4 mismatched character ' ' expecting ','
line 1:6 mismatched character 'i' expecting ','
line 1:8 mismatched character 't' expecting ','
line 1:10 mismatched ch...

I'm not surprised it's not tokenized the characters into words because of
it's inability to find the lexer rules corresponding to the tokens but I'm
not sure why it only reads every second char.

Finding the lexer rules is the prime problem but I'm curious if someone
could explain the second too.

BTW - my tokenVocab attribute appears to be correct because when it's not
there the editor shows all my tokens as being unknown and underlined in
red.

Thanks for your help.  I really like this IDE but this whole field has quite
a learning curve </understatement>

Thanks,

alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080306/eeee1ad4/attachment.html 


More information about the antlr-interest mailing list