[antlr-interest] expecting "select", found 's'
Olivier - (JConcept / Cetip21)
Olivier at cetip.com.br
Wed Aug 24 10:45:29 PDT 2005
Hi,
I am trying to build a simple query parser for query like select x where x.name = 'marc'
but i get the following error when writing select x where x.name = marc
line 1:1: expecting "select", found 's'
line 1:23: unexpected char: '='
at mypackage.graph.parser.GraphLexer.nextToken(GraphLexer.java:186)
at antlr.TokenBuffer.fill(TokenBuffer.java:69)
at antlr.TokenBuffer.LA(TokenBuffer.java:80)
at antlr.LLkParser.LA(LLkParser.java:52)
at antlr.Parser.consumeUntil(Parser.java:149)
at antlr.Parser.recover(Parser.java:312)
at mypackage.query.parser.DialogyQueryParser.query(DialogyQueryParser.java:69)
at mypackage.query.parser.Test.main(Test.java:30)
Exception in thread "main"
any idea ?
Thanks.
Here is my grammar :
class DialogyQueryParser extends Parser;
{}
query: SELECT identifier WHERE complexExpression ;
complexExpression : simpleExpression;
simpleExpression : identifier (POINT identifier EQUAL identifier | identifier identifier);
/** Matches a valid identifier*/
identifier : IDENTIFIER;
class QueryLexer extends Lexer;
options {
testLiterals = true;
k = 2;
caseSensitive = false;
caseSensitiveLiterals = false;
charVocabulary = '\3' .. '\177';
}
tokens {
SELECT="select";
WHERE="where";
OR="or";
AND="and";
}
IDENTIFIER options { testLiterals=true; }
:
'a' .. 'z' ( 'a' .. 'z' | '0' .. '9' | '_' | '$' | '#' )*
;
LPAREN: '(' ;
RPAREN: ')' ;
LCURLY_BRACE: '{' ;
RCURLY_BRACE: '}' ;
EQUAL:'=';
COMMA:',';
POINT:'.';
//INT : ('0'..'9')+ ;
//LETTER:('a'..'z')+;
WS : ( ' '
| '\r' '\n'
| '\n'
| '\t'
)
{$setType(Token.SKIP);}
;
Atenção: Esta mensagem foi enviada para uso exclusivo do(s) destinatários(s) acima
identificado(s), podendo conter informações e/ou documentos
confidencias/privilegiados e seu sigilo é protegido por lei.
Caso você tenha recebido por engano, por favor, informe o remetente e apague-a de
seu sistema.
Notificamos que é proibido por lei a sua retenção, disseminação, distribuição, cópia ou
uso sem expressa autorização do remetente.
Opiniões pessoais do remetente não refletem, necessariamente, o ponto de vista da
CETIP, o qual é divulgado somente por pessoas autorizadas.
Attention: This message was sent for exclusive use of the addressees above
identified, being able to contain information and or privileged/confidential documents
and law protects its secrecies.
In case that you it has received for deceit, please, it informs the shipper and erases it
of your system.
We notify that law forbids its retention, dissemination, distribution, copy or use without
express authorization.
Personal opinions of the shipper do not reflect, necessarily, the point of view of the
CETIP, which is only divulged by authorized people.
More information about the antlr-interest
mailing list