[antlr-interest] errors reported in console

Java Developer javadev111 at gmail.com
Tue Mar 17 03:56:18 PDT 2009


My example grammar file is shown below (end). I am using ANTLRWorks 1.2.3.
When I enter "bab be baj" in the interpreter, I see the parse tree
correctly. However, I see also that there are errors reported in the
console. When I look at the console, I see the output below. What does this
mean? Is this a problem with my grammar?

[06:41:35] error(208): test.g:24:1: The following token definitions can
never be matched because prior tokens match the same input: SECOND
[06:41:35] Interpreting...
[06:41:35] problem matching token at 1:4 NoViableAltException(' '@[1:1:
Tokens : ( CODE | FIRST | SECOND | THIRD );])
[06:41:35] problem matching token at 1:7 NoViableAltException(' '@[1:1:
Tokens : ( CODE | FIRST | SECOND | THIRD );])

//GRAMMAR FILE
grammar test;

//http://www.antlr.org/wiki/display/ANTLR3/Grammar+options
options {
    language=Java;
    output=AST;
        ASTLabelType=CommonTree;
}

//http://www.antlr.org/wiki/display/ANTLR3/Grammars
@header {
package com.test.parser.antlr;
}

@lexer::header {
package com.test.parser.antlr;
}

expr    :    (CODE)+;
CODE:    (FIRST)? SECOND (THIRD)?;

FIRST:
    ('b');
SECOND:
    ('a'|'e'|'i'|'o'|'u');
THIRD:
    ('b'|'j'|'v'|'g'|'s'|'m'|'d');
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090317/ebce37b0/attachment.html 


More information about the antlr-interest mailing list