【发布时间】:2014-11-26 17:25:16
【问题描述】:
这是一个简单的 SQL 选择语句语法
grammar SQL;
@rulecatch {
//We want to stop parsing when SyntaxException is encountered
//So we re-throw the exception
catch (SyntaxException e) {
throw e;
}
}
eval
: sql_query
;
sql_query
: select_statement from_statement
| select_statement from_statement where_statement
;
select_statement
: 'select' attribute_list
;
from_statement
: 'from' table_name
;
where_statement
: 'where' attribute_name operator constant
;
attribute_list
: '*'
| attribute_name
| attribute_name ',' attribute_list?
;
table_name
: string_literal
;
attribute_name
: string_literal
;
operator
: '=' | '!=' | '>' | '>=' | '<' | '<='
;
constant
: INTEGER
| '"' string_literal '"'
;
fragment DIGIT: '0'..'9';
INTEGER: DIGIT+ ;
fragment LETTER: 'a'..'z'|'A'..'Z';
string_literal: LETTER | LETTER string_literal;
WS : (' ' | '\t' | '\n' | '\r' | '\f')+ {$channel=HIDDEN;};
该工具正在唠叨sql_query 定义以及attribute_list 定义。老实说,我一开始在我的代码中看不到任何左递归。
谁能解释一下是怎么回事?
【问题讨论】:
-
发布确切的错误信息总是好的。
标签: recursion antlr ll left-recursion