Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.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
Bison 野牛通用识别命令_Bison - Fatal编程技术网

Bison 野牛通用识别命令

Bison 野牛通用识别命令,bison,Bison,我正在开发一个野牛程序,需要有最后一个选项,允许它识别任何东西。很像其他的如果 谢谢 commands: F{ t[top++] = 'F'; } |PLUS{ t[top++] = '+'; } |MINUS{ t[topo++] = '-'; } |ACOL { t[top++] = '[

我正在开发一个野牛程序,需要有最后一个选项,允许它识别任何东西。很像其他的如果

谢谢

commands: F{
            t[top++] = 'F';
            }
      |PLUS{
            t[top++] = '+';
            }
      |MINUS{
            t[topo++] = '-';
            }
      |ACOL { 
            t[top++] = '[';
            }
      |FCOL{
            t[top++] = ']';
            }
      |POINT{
             t[top++] = '.';
            }
      |EQUAL {
            t[top++] = '=';
            }
      | {  
           /* generic command should be here
           if any of the commands above were found it should run whatever is here*/
      }

附加在标记非终端中识别出任何命令令牌后要运行的逻辑,如下所示。请注意,
标记
的产品右侧与任何标记都不匹配

command_and_marker: command marker;

command:  F
            {
            t[top++] = 'F';
            }
        | PLUS
            {
            t[top++] = '+';
            }
        | MINUS
            {
            t[topo++] = '-';
            }
        | ACOL
            { 
            t[top++] = '[';
            }
        | FCOL
            {
            t[top++] = ']';
            }
        | POINT
            {
            t[top++] = '.';
            }
        | EQUAL
            {
            t[top++] = '=';
            } 
marker:     {  
            /* generic command should be here
            if any of the commands above were found it should run whatever is here*/
            }

我已经制定了我的答案来匹配代码中的注释,这些注释与您的问题文本有点不一致。如果您希望
command
匹配任何内容,而不仅仅是
F
PLUS
等,那么您必须拼写出您的lexer可以在
command
的产品中生成的所有标记。这不一定是一个好主意,有几个原因。

附加在标记非终端中识别出任何命令令牌后要运行的逻辑,如下所示。请注意,
标记
的产品右侧与任何标记都不匹配

command_and_marker: command marker;

command:  F
            {
            t[top++] = 'F';
            }
        | PLUS
            {
            t[top++] = '+';
            }
        | MINUS
            {
            t[topo++] = '-';
            }
        | ACOL
            { 
            t[top++] = '[';
            }
        | FCOL
            {
            t[top++] = ']';
            }
        | POINT
            {
            t[top++] = '.';
            }
        | EQUAL
            {
            t[top++] = '=';
            } 
marker:     {  
            /* generic command should be here
            if any of the commands above were found it should run whatever is here*/
            }
我已经制定了我的答案来匹配代码中的注释,这些注释与您的问题文本有点不一致。如果您希望
command
匹配任何内容,而不仅仅是
F
PLUS
等,那么您必须拼写出您的lexer可以在
command
的产品中生成的所有标记。出于几个原因,这不一定是个好主意