⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 y_tab.c

📁 现将本人搜集常用的程序设计语言的词法和形式文法提供给大家。其中
💻 C
📖 第 1 页 / 共 3 页
字号:
  277,  260,  279,  187,  281,  174,  283,  284,  219,  286,
   43,   -1,   45,   -1,  259,   -1,  261,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,  261,  262,  263,   60,   61,   62,
   -1,  268,  269,   -1,   -1,  272,   -1,  274,  275,   -1,
  277,   -1,  279,   -1,  281,   -1,  283,  284,   -1,  286,
   -1,   -1,  261,  262,  263,   -1,  301,   -1,   -1,  268,
  269,   -1,   -1,  272,   -1,  274,  275,   -1,  277,   -1,
  279,   -1,  281,   -1,  283,  284,   -1,  286,  182,   -1,
   -1,   -1,  264,   -1,   -1,   -1,   -1,   66,   67,   -1,
   69,   -1,   -1,  275,   -1,   -1,   -1,  279,   86,   -1,
   88,   -1,   90,   -1,  286,  261,  262,  263,   -1,  213,
   -1,   -1,  268,  269,   -1,   -1,  272,   -1,  274,  275,
   99,  277,   -1,  279,   -1,  281,   -1,  283,  284,  272,
  286,  274,  275,   -1,  277,   -1,  279,   -1,  281,   -1,
  283,  284,  121,  286,  132,  133,  125,   -1,   -1,  128,
   -1,   -1,   -1,   -1,   -1,   -1,  260,   -1,   -1,  263,
   -1,   -1,   -1,   -1,  261,  262,  263,   -1,   -1,   -1,
   -1,  268,  269,   -1,   -1,  272,   -1,  274,  275,   -1,
  277,   -1,  279,   -1,  281,   -1,  283,  284,   -1,  286,
   -1,   -1,  296,   -1,  182,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,  183,   -1,  185,   -1,   -1,  313,
   -1,   -1,  260,  201,   -1,  260,   -1,   -1,   -1,   -1,
  208,  209,   -1,   -1,   -1,  213,   -1,   -1,  261,  262,
  263,  260,   -1,   -1,   -1,  268,  269,  285,  217,   -1,
  285,  289,  290,  291,  289,  290,  291,   -1,  296,  297,
  298,  296,  297,  298,   -1,  234,  285,   -1,  237,  238,
  289,  290,  291,   -1,   -1,   -1,   -1,  296,  297,  298,
  257,   -1,  260,  260,   -1,  263,   -1,   -1,   -1,   -1,
   -1,   -1,  270,   -1,   -1,   -1,  273,  266,   -1,  276,
  278,  278,   -1,  280,   -1,  282,   -1,   -1,  285,   -1,
  287,  288,   -1,   -1,   -1,   -1,  294,   -1,  296,   -1,
   -1,   -1,   -1,  292,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,  313,
};
#define YYFINAL 2
#ifndef YYDEBUG
#define YYDEBUG 1
#endif
#define YYMAXTOKEN 300
#if YYDEBUG
char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0,0,0,0,0,0,0,0,
"':'","';'","'<'","'='","'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"UNSIGNED_INT","UNSIGNED_REAL","STRING",
"IDENTIFIER","NE","LE","GE","BECOMES","DIV","MOD","NIL","IN","OR","AND","NOT",
"DOTDOT","IF","THEN","ELSE","CASE","OF","REPEAT","UNTIL","WHILE","DO","FOR",
"TO","DOWNTO","SBEGIN","END","WITH","GOTO","CONST","VAR","TYPE","ARRAY",
"RECORD","SET","SFILE","FUNCTION","PROCEDURE","LABEL","PACKED","PROGRAM",
};
char *yyrule[] = {
"$accept : program",
"$$1 :",
"program : PROGRAM $$1 newident external_files ';' block '.'",
"external_files :",
"$$2 :",
"external_files : '(' $$2 newident_list ')'",
"block : opt_declarations statement_part",
"opt_declarations :",
"opt_declarations : declarations",
"declarations : declarations declaration",
"declarations : declaration",
"declaration : label_dcl_part",
"declaration : const_dcl_part",
"declaration : type_dcl_part",
"declaration : var_dcl_part",
"declaration : proc_dcl_part",
"label_dcl_part : LABEL labels ';'",
"labels : labels ',' label",
"labels : label",
"label : UNSIGNED_INT",
"const_dcl_part : CONST const_defs ';'",
"const_defs : const_defs ';' const_def",
"const_defs : const_def",
"$$3 :",
"const_def : $$3 newident '=' constant",
"constant : unsigned_num",
"constant : '+' unsigned_num",
"constant : '-' unsigned_num",
"constant : ident",
"constant : '+' ident",
"constant : '-' ident",
"constant : STRING",
"unsigned_num : UNSIGNED_INT",
"unsigned_num : UNSIGNED_REAL",
"type_dcl_part : TYPE type_defs ';'",
"type_defs : type_defs ';' type_def",
"type_defs : type_def",
"$$4 :",
"type_def : $$4 newident '=' type",
"type : simple_type",
"type : PACKED struct_type",
"type : struct_type",
"type : '^' IDENTIFIER",
"$$5 :",
"simple_type : '(' $$5 newident_list ')'",
"simple_type : constant DOTDOT constant",
"simple_type : ident",
"struct_type : ARRAY '[' index_t_list ']' OF type",
"struct_type : RECORD field_list END",
"struct_type : SET OF simple_type",
"struct_type : SFILE OF type",
"index_t_list : index_t_list ',' simple_type",
"index_t_list : simple_type",
"field_list : fixed_part",
"field_list : fixed_part ';' variant_part",
"field_list : variant_part",
"fixed_part : fixed_part ';' record_section",
"fixed_part : record_section",
"$$6 :",
"record_section : $$6 newident_list ':' type",
"record_section :",
"$$7 :",
"variant_part : CASE $$7 tag_field OF variants",
"tag_field : newident ':' ident",
"tag_field : ident",
"variants : variants ';' variant",
"variants : variant",
"variant : case_label_list ':' '(' field_list ')'",
"variant :",
"var_dcl_part : VAR variable_dcls ';'",
"variable_dcls : variable_dcls ';' variable_dcl",
"variable_dcls : variable_dcl",
"$$8 :",
"variable_dcl : $$8 newident_list ':' type",
"newident_list : new_id_list",
"new_id_list : new_id_list ',' newident",
"new_id_list : newident",
"proc_dcl_part : proc_or_func",
"proc_or_func : proc_heading ';' body ';'",
"proc_or_func : func_heading ';' body ';'",
"$$9 :",
"$$10 :",
"proc_heading : PROCEDURE $$9 newident $$10 formal_params",
"$$11 :",
"$$12 :",
"func_heading : FUNCTION $$11 newident $$12 function_form",
"function_form :",
"function_form : formal_params ':' ident",
"body : block",
"body : IDENTIFIER",
"formal_params :",
"$$13 :",
"formal_params : '(' $$13 formal_p_sects ')'",
"formal_p_sects : formal_p_sects ';' formal_p_sect",
"formal_p_sects : formal_p_sect",
"$$14 :",
"formal_p_sect : $$14 param_group",
"$$15 :",
"formal_p_sect : VAR $$15 param_group",
"$$16 :",
"formal_p_sect : $$16 proc_heading",
"$$17 :",
"formal_p_sect : $$17 func_heading",
"param_group : newident_list ':' paramtype",
"paramtype : ident",
"paramtype : ARRAY '[' index_specs ']' OF paramtype",
"paramtype : PACKED ARRAY '[' index_spec ']' OF ident",
"index_specs : index_specs ';' index_spec",
"index_specs : index_spec",
"$$18 :",
"index_spec : $$18 newident DOTDOT newident ':' ident",
"statement_part : compound_stmt",
"compound_stmt : SBEGIN statements END",
"statements : statements ';' statement",
"statements : statement",
"statement :",
"statement : label ':' statement",
"statement : compound_stmt",
"statement : assignment",
"statement : procedure_call",
"statement : GOTO label",
"statement : IF expression THEN statement",
"statement : IF expression THEN statement ELSE statement",
"statement : CASE expression OF case_list END",
"statement : WHILE expression DO statement",
"statement : REPEAT statements UNTIL expression",
"statement : FOR ident BECOMES expression direction expression DO statement",
"statement : WITH rec_var_list DO statement",
"direction : TO",
"direction : DOWNTO",
"assignment : variable BECOMES expression",
"procedure_call : ident actual_params",
"actual_params :",
"actual_params : '(' actuals_list ')'",
"actuals_list : actuals_list ',' actual_param",
"actuals_list : actual_param",
"actual_param : expression",
"actual_param : expression colon_things",
"colon_things : ':' expression",
"colon_things : ':' expression ':' expression",
"case_list : case_list ';' case_list_elem",
"case_list : case_list_elem",
"case_list_elem : case_label_list ':' statement",
"case_list_elem :",
"case_label_list : case_label_list ',' case_label",
"case_label_list : case_label",
"case_label : constant",
"rec_var_list : rec_var_list ',' record_var",
"rec_var_list : record_var",
"expression : simple_expr",
"expression : simple_expr relational_op simple_expr",
"relational_op : '='",
"relational_op : '<'",
"relational_op : '>'",
"relational_op : LE",
"relational_op : GE",
"relational_op : NE",
"relational_op : IN",
"simple_expr : term",
"simple_expr : '+' term",
"simple_expr : '-' term",
"simple_expr : simple_expr add_op term",
"add_op : '+'",
"add_op : '-'",
"add_op : OR",
"term : factor",
"term : term mult_op factor",
"mult_op : '*'",
"mult_op : '/'",
"mult_op : DIV",
"mult_op : MOD",
"mult_op : AND",
"factor : variable",
"factor : unsigned_lit",
"factor : '(' expression ')'",
"factor : set",
"factor : NOT factor",
"unsigned_lit : unsigned_num",
"unsigned_lit : STRING",
"unsigned_lit : NIL",
"set : '[' member_list ']'",
"member_list :",
"member_list : members",
"members : members ',' member",
"members : member",
"member : expression",
"member : expression DOTDOT expression",
"variable : ident actual_params",
"variable : variable '[' expressions ']'",
"variable : variable '.' ident",
"variable : variable '^'",
"expressions : expressions ',' expression",
"expressions : expression",
"record_var : variable",
"ident : IDENTIFIER",
"newident : IDENTIFIER",
};
#endif
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
#define yyclearin (yychar=(-1))
#define yyerrok (yyerrflag=0)
#ifdef YYSTACKSIZE
#ifndef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#endif
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 600
#define YYMAXDEPTH 600
#endif
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
short *yyssp;
YYSTYPE *yyvsp;
YYSTYPE yyval;
YYSTYPE yylval;
short yyss[YYSTACKSIZE];
YYSTYPE yyvs[YYSTACKSIZE];
#define yystacksize YYSTACKSIZE
#line 337 "pascal.y"
   /*start of routines*/

yyerror(msg) char *msg;
{
    if(msg==NULL || *msg=='\0')
	fprintf(stderr, "Error at %s near line %d\n",
				token_name(yychar), linenumber);
    else
	fprintf(stderr, "Error at %s near line %d : %s\n",
				token_name(yychar), linenumber, msg);
    exit(1);
}

parser_info()
{
    printf("\n%d line%s parsed\n", linenumber, plural(linenumber));
}


internal_error(s,a1,a2,a3,a4)
{
    fprintf(stderr, "Internal error: ");
    fprintf(stderr, s, a1, a2, a3, a4);
    exit(2);
}

warning(fmt, a1, a2, a3, a4)
{
    fprintf(stderr, "Warning line %d: ", linenumber);
    fprintf(stderr, fmt, a1, a2, a3, a4);
    fprintf(stderr, "\n");
}

main()
{
    yyparse();
}
#line 700 "y_tab.c"
#define YYABORT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
#if YYDEBUG
#ifndef YYDEBUG_LEXER_TEXT /* pointer to the text isolated by the lexer*/
#define YYDEBUG_LEXER_TEXT "YYDEBUG_LEXER_TEXT not defined"
#endif
#ifndef YYDEBUG_INDENT_STRING
#define YYDEBUG_INDENT_STRING  "|       "
#endif
#ifndef YYDEBUG_REDUCE_STRING
#define YYDEBUG_REDUCE_STRING  "+-------"
#endif
#ifndef YYDEBUG_INDENT
YYDEBUG_INDENT(yyindent)
int yyindent;
{
    while(yyindent-- > 0)
        printf("%s", YYDEBUG_INDENT_STRING);
}
#endif /* YYDEBUG_INDENT */
#ifndef YYDEBUG_REDUCE
YYDEBUG_REDUCE(yynew_state, yyrule_num, yyrule_string, yynew_indent, 
yyrhs_count)
int yynew_state;
int yyrule_num;
char * yyrule_string;
int yynew_indent;
int yyrhs_count;
{
    if (1 < yyrhs_count)
    {  /* draw the graphics for the reduction */
        YYDEBUG_INDENT(yynew_indent);
        while(1 < yyrhs_count--)
            printf("%s", YYDEBUG_REDUCE_STRING);
        putchar('+'); /* left rotated L would look nice */
        putchar('\n');
        YYDEBUG_INDENT(yynew_indent);
        putchar('|'); /* down arrow would look nice */
        putchar('\n');
    }
    YYDEBUG_INDENT(yynew_indent);
    /* Only print the resulting token name */
    while (*yyrule_string && ' ' != *yyrule_string)
        putchar(*yyrule_string++);
    putchar('\n');
}
#endif /* YYDEBUG_REDUCE */
#ifndef YYDEBUG_SHIFT_LEXEME
YYDEBUG_SHIFT_LEXEME(yyold_state, yynew_state, yytoken_string, yynew_indent)
int yyold_state;
int yynew_state;
char * yytoken_string;
int yynew_indent;
{
    YYDEBUG_INDENT(yynew_indent);
    printf("%s <-- `%s'\n", yytoken_string, YYDEBUG_LEXER_TEXT);
}
#endif /*  YYDEBUG_SHIFT_LEXEME */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -