hi, i am constructing a MySQL grammar validator with antlr. i started
with the sql_yacc.yy from mysql source code, but i have some
difficulties converting the following grammar, i tried many times, but
it is obvious i am not good at it. is anyone can help me?
thanks a lot.
/* all possible expressions */
expr:
expr or expr
| expr XOR expr
| expr and expr
| NOT_SYM expr
| bool_pri IS TRUE_SYM
| bool_pri IS not TRUE_SYM
| bool_pri IS FALSE_SYM
| bool_pri IS not FALSE_SYM
| bool_pri IS UNKNOWN_SYM
| bool_pri IS not UNKNOWN_SYM
| bool_pri
;
bool_pri:
bool_pri IS NULL_SYM
| bool_pri IS not NULL_SYM
| bool_pri EQUAL_SYM predicate
| bool_pri comp_op predicate
| bool_pri comp_op all_or_any '(' subselect ')'
| predicate
;
predicate:
bit_expr IN_SYM '(' subselect ')'
| bit_expr not IN_SYM '(' subselect ')'
| bit_expr IN_SYM '(' expr ')'
| bit_expr IN_SYM '(' expr ',' expr_list ')'
| bit_expr not IN_SYM '(' expr ')'
| bit_expr not IN_SYM '(' expr ',' expr_list ')'
| bit_expr BETWEEN_SYM bit_expr AND_SYM predicate
| bit_expr not BETWEEN_SYM bit_expr AND_SYM predicate
| bit_expr SOUNDS_SYM LIKE bit_expr
| bit_expr LIKE simple_expr opt_escape
| bit_expr not LIKE simple_expr opt_escape
| bit_expr REGEXP bit_expr
| bit_expr not REGEXP bit_expr
| bit_expr
;
bit_expr:
bit_expr '|' bit_expr
| bit_expr '&' bit_expr
| bit_expr SHIFT_LEFT bit_expr
| bit_expr SHIFT_RIGHT bit_expr
| bit_expr '+' bit_expr
| bit_expr '-' bit_expr
| bit_expr '+' INTERVAL_SYM expr interval
| bit_expr '-' INTERVAL_SYM expr interval
| bit_expr '*' bit_expr
| bit_expr '/' bit_expr
| bit_expr '%' bit_expr
| bit_expr DIV_SYM bit_expr
| bit_expr MOD_SYM bit_expr
| bit_expr '^' bit_expr
| simple_expr
;
simple_expr:
simple_ident
| function_call_keyword
| function_call_nonkeyword
| function_call_generic
| function_call_conflict
| simple_expr COLLATE_SYM ident_or_text
| literal
| param_marker
| variable
| sum_expr
| simple_expr OR_OR_SYM simple_expr
| '+' simple_expr
| '-' simple_expr
| '~' simple_expr
| not2 simple_expr
| '(' subselect ')'
| '(' expr ')'
| '(' expr ',' expr_list ')'
| ROW_SYM '(' expr ',' expr_list ')'
| EXISTS '(' subselect ')'
| ''
| MATCH ident_list_arg AGAINST '(' bit_expr fulltext_options ')'
| BINARY simple_expr
| CAST_SYM '(' expr AS cast_type ')'
| CASE_SYM opt_expr when_list opt_else END
| CONVERT_SYM '(' expr ',' cast_type ')'
| CONVERT_SYM '(' expr USING charset_name ')'
| DEFAULT '(' simple_ident ')'
| VALUES '(' simple_ident_nospvar ')'
| INTERVAL_SYM expr interval '+' expr
/* we cannot put interval before - */
;
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.