Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/authentication/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sas bison中使用空规则减少移位错误_Sas_Grammar_Yacc_Lex_Shift Reduce Conflict - Fatal编程技术网

Sas bison中使用空规则减少移位错误

Sas bison中使用空规则减少移位错误,sas,grammar,yacc,lex,shift-reduce-conflict,Sas,Grammar,Yacc,Lex,Shift Reduce Conflict,我有以下yacc语法: OPTIONS:OPTIONS OPTION {printf("%s\n", "Options enabled");} | OPTION {printf("%s\n", "First option");} | ; OPTION: DEBUG {printf("%s\n", "

我有以下yacc语法:

OPTIONS:OPTIONS OPTION                  {printf("%s\n", "Options    enabled");}
        | OPTION                        {printf("%s\n",     "First option");}
        |
        ;

OPTION:   DEBUG                         {printf("%s\n",   "debug enabled");}
        | NESTING                       {printf("%s\n", "nesting enabled");}
        | '(' STACK '=' NAME ')'        {printf("%s\n", "stack size given");}
    | NOLIST                        {printf("%s\n", "nolist enabled");}
    | VIEW EQ NAME                  {printf("%s\n", "this is a view, first name is view name");}
    ;
对于空规则,它给了我移位/减少错误。错误的Y.output文件如下所示:

17 OPTIONS: . OPTIONS OPTION
18        | . OPTION
19        | .  [SEMICOLON, VIEW, DEBUG, NESTING, NOLIST, '(']
20 OPTION: . DEBUG
21       | . NESTING
22       | . '(' STACK '=' NAME ')'
23       | . NOLIST
24       | . VIEW EQ NAME

NAME     shift, and go to state 4
VIEW     shift, and go to state 11
DEBUG    shift, and go to state 12
NESTING  shift, and go to state 13
NOLIST   shift, and go to state 14
'('      shift, and go to state 15

VIEW      [reduce using rule 19 (OPTIONS)]
DEBUG     [reduce using rule 19 (OPTIONS)]
NESTING   [reduce using rule 19 (OPTIONS)]
NOLIST    [reduce using rule 19 (OPTIONS)]
'('       [reduce using rule 19 (OPTIONS)]
$default  reduce using rule 19 (OPTIONS)

有人能建议如何解决这个问题吗?

您有一个关于规则选项的递归。冲突的存在是因为有两种方法可以停止递归。例如,如果您只有一个选项,那么有两个不同的解析树

OPTIONS         or                OPTIONS
   |                               |    \
 OPTION                        OPTIONS  OPTION
   |                               |
  ...                       "empty rule"
因此,删除空规则或
选项:OPTION
(维护空规则),问题就应该消失了