[antlr-interest] Problem with Lexer.. may be a bug
Alexandre Porcelli
porcelli at uol.com.br
Tue Apr 24 06:55:46 PDT 2007
Hi...
About the COMMENTED_TEXT, I declared it in Tokens sections, and I'm
using it in: AUTHOR, INSTALLATION, DATE_WRITTEN, DATE_COMPILED,
SECURITY and REMARKS (ProblemCobolGrammar.g).... I'm generating this
lex rule manually (ex: see lines 140-142).
I'm using the ANTLRWorks, I tried to compile and debug directly..
and works without error messages... but the lexer seems that is not
working properly, generating the following the following error errors
messages during a test execution:
line 1:9 mismatched character 'd' expecting 's'
line 1:11 no viable alternative at character 'n'
line 1:23 rule DATE_WRITTEN failed predicate: {getCharPositionInLine()
>= 7 && getCharPositionInLine() <= 10}?
line 1:25 mismatched character 'v' expecting 's'
line 1:27 rule SECURITY failed predicate: {getCharPositionInLine() >=
7 && getCharPositionInLine() <= 10}?
line 1:29 mismatched character 'o' expecting 's'
line 1:12 mismatched input 'tification' expecting ID_DIVISION
I tested using this text:
identification division.
program-id. teste.
author. ahg asjdhfg kshjdfg kadfka dhj
environment
Best Regards,
Alexandre Porcelli
On 4/24/07, Gavin Lambert <antlr at mirality.co.nz> wrote:
> At 02:20 24/04/2007, Alexandre Porcelli wrote:
> > I have a problem with my lex rules... I have 5 similar
> rules...
> >when I try to use all of then.. i got the following error
> message:
> >
> >"ANTLR could not analyze this decision in rule Tokens; often
> this
> >is because of recursive rule references visible from the left
> edge
> >of alternatives. ANTLR will re-analyze the decision with a
> fixed
> >lookahead of k=1. Consider using "options {k=1;}" for that
> >decision and possibly adding a syntactic predicate."
>
> Well, I'm not sure why it'd generate that particular message (it
> doesn't for me), but the grammars you attached appear to declare
> and use COMMENTED_TEXT without actually defining it, which is
> illegal.
>
>
More information about the antlr-interest
mailing list