[antlr-interest] weird errors in antlr3

Ymo ymo.mail at gmail.com
Fri Mar 14 18:28:44 PDT 2008


Anyone can explain why i keep getting this error ? I am a newby in grammar
land


input file :
<%for select="heh" /%for>

output error:
line 1:14 no viable alternative at character 't'
line 1:15 no viable alternative at character 'e'
line 1:17 mismatched character 't' expecting 'e'
BR.recoverFromMismatchedToken
line 0:-1 mismatched input '<EOF>' expecting '\"'
BR.recoverFromMismatchedToken
tree=nil



grammar :
grammar TTest;
options {
   k=2;
   backtrack=true;
   memoize=true;
   output=AST;
   ASTLabelType=CommonTree;
}

@lexer::members {
protected boolean enumIsKeyword = true;
}

@lexer::header {
package org.ttest.core;
}

@parser::header {
package org.ttest.core;

import java.util.Set;
import java.util.HashSet;

}

compilationUnit
    : templateForStatement
    ;

templateForStatement
    :    '<%for' templateXpathStatement '/%for>'
    ;

templateXpathStatement
    : 'select' '=' xpathExpression
    ;

xpathExpression
    : ( '\"' (~'\"')* '\"'
    | '\'' (~'\'')* '\''
    )
    ;

WS  :  (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;}
    ;

COMMENT
    :   '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
    ;

LINE_COMMENT
    : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
    ;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080314/a390db5e/attachment.html 


More information about the antlr-interest mailing list