Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.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
Error handling 在yacc中,如果给定的输入与任何规则都不匹配,我们如何在输出中以相同的格式返回输入_Error Handling_Default_Yacc - Fatal编程技术网

Error handling 在yacc中,如果给定的输入与任何规则都不匹配,我们如何在输出中以相同的格式返回输入

Error handling 在yacc中,如果给定的输入与任何规则都不匹配,我们如何在输出中以相同的格式返回输入,error-handling,default,yacc,Error Handling,Default,Yacc,请在下面找到我的代码: function_definition : declaration_specifiers declarator declaration_list {printf("in function definition \n");}compound_statement | declaration_specifiers declarator {printf("in function definition \n");}compound_statement |

请在下面找到我的代码:

function_definition
    : declaration_specifiers  declarator declaration_list {printf("in function definition \n");}compound_statement
    | declaration_specifiers  declarator {printf("in function definition \n");}compound_statement
    | declarator declaration_list {printf("in function definition \n");} compound_statement
    | declarator {printf("in function definition \n");} compound_statement {my_fun($<block_item_struct>2); printf("in function definition\n");}
    | direct_declarator ';'  {
                            $<fun_ptyp>$ = $<multi_type>1;
    }

    | error  {char * text ; $<symbol_table>$->cb = malloc(sizeof(struct code_block));text = strdup(yytext);$<symbol_table>$->cb->function_call= text;$<symbol_table>$->cb->pos =yylineno;
                *yytext=NULL;printf("error: %s at line no %d\n",$<symbol_table>$->cb->function_call,$<symbol_table>$->cb->pos);**
             }
    ;

简而言之,你不能。输入已标记化。NB
yacc
不使用正则表达式。有没有办法绕过lex的标记化,在yacc中有一个默认规则来匹配所有与其他规则不匹配的规则。
Ex: /* This function takes care of tree implementation .
    The parameters passed are char* and  int */