<i id='uYy71'><tr id='uYy71'><dt id='uYy71'><q id='uYy71'><span id='uYy71'><b id='uYy71'><form id='uYy71'><ins id='uYy71'></ins><ul id='uYy71'></ul><sub id='uYy71'></sub></form><legend id='uYy71'></legend><bdo id='uYy71'><pre id='uYy71'><center id='uYy71'></center></pre></bdo></b><th id='uYy71'></th></span></q></dt></tr></i><div id='uYy71'><tfoot id='uYy71'></tfoot><dl id='uYy71'><fieldset id='uYy71'></fieldset></dl></div>
<tfoot id='uYy71'></tfoot>
    <bdo id='uYy71'></bdo><ul id='uYy71'></ul>

  1. <legend id='uYy71'><style id='uYy71'><dir id='uYy71'><q id='uYy71'></q></dir></style></legend>

    <small id='uYy71'></small><noframes id='uYy71'>

    1. 如何将 MySQL yacc 语法转换为 antlr LL(1)?

      时间:2023-08-21
    2. <i id='0gfpA'><tr id='0gfpA'><dt id='0gfpA'><q id='0gfpA'><span id='0gfpA'><b id='0gfpA'><form id='0gfpA'><ins id='0gfpA'></ins><ul id='0gfpA'></ul><sub id='0gfpA'></sub></form><legend id='0gfpA'></legend><bdo id='0gfpA'><pre id='0gfpA'><center id='0gfpA'></center></pre></bdo></b><th id='0gfpA'></th></span></q></dt></tr></i><div id='0gfpA'><tfoot id='0gfpA'></tfoot><dl id='0gfpA'><fieldset id='0gfpA'></fieldset></dl></div>

            <bdo id='0gfpA'></bdo><ul id='0gfpA'></ul>

            <legend id='0gfpA'><style id='0gfpA'><dir id='0gfpA'><q id='0gfpA'></q></dir></style></legend>

            <small id='0gfpA'></small><noframes id='0gfpA'>

              <tbody id='0gfpA'></tbody>
            1. <tfoot id='0gfpA'></tfoot>

                本文介绍了如何将 MySQL yacc 语法转换为 antlr LL(1)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在用 ANTLR 构建一个 MySQL 语法验证器.我从 MySQL 源代码中的 sql_yacc.yy 开始,但我在转换以下语法时遇到了一些困难.我尝试了很多次,但它不起作用.有人可以帮我吗?

                I am constructing a MySQL grammar validator with ANTLR. I started with the sql_yacc.yy from the MySQL source code, but I have some difficulties converting the following grammar. I tried many times, but it doesn't work. Can anyone help me?

                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
                  ;
                

                推荐答案

                ANTLR 无法应对 left-recursion,因此没有简单的方法可以将 sql_yacc.yy 转换为 ANTLR 等效项.您可能想查看 ANTLR Wiki 中的以下资源:

                ANTLR cannot cope with left-recursion, so there's no trivial way to convert sql_yacc.yy into the ANTLR equivalent. You might want to have a look at the following resources from the ANTLR Wiki:

                • 左递归移除
                • MySQL 方言 (ANTLR v3) 的 SQL 语法

                请注意,MySQL 语法不完整,但可能会给您一个起点.

                Note that the MySQL grammar is incomplete, but might give you a starting point.

                这篇关于如何将 MySQL yacc 语法转换为 antlr LL(1)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使用 ANT 任务启动 MySql 下一篇:phpmyadmin 中的奇怪错误,它已成功安装但仍然无法

                相关文章

                最新文章

                <legend id='0tlhq'><style id='0tlhq'><dir id='0tlhq'><q id='0tlhq'></q></dir></style></legend>

                  <small id='0tlhq'></small><noframes id='0tlhq'>

                    <bdo id='0tlhq'></bdo><ul id='0tlhq'></ul>

                1. <i id='0tlhq'><tr id='0tlhq'><dt id='0tlhq'><q id='0tlhq'><span id='0tlhq'><b id='0tlhq'><form id='0tlhq'><ins id='0tlhq'></ins><ul id='0tlhq'></ul><sub id='0tlhq'></sub></form><legend id='0tlhq'></legend><bdo id='0tlhq'><pre id='0tlhq'><center id='0tlhq'></center></pre></bdo></b><th id='0tlhq'></th></span></q></dt></tr></i><div id='0tlhq'><tfoot id='0tlhq'></tfoot><dl id='0tlhq'><fieldset id='0tlhq'></fieldset></dl></div>
                  1. <tfoot id='0tlhq'></tfoot>