📄 parse.y
字号:
"Discouraged form of returned type specification"); }| identifier OP_TK error {yyerror ("')' expected"); DRECOVER(method_declarator);}| method_declarator OSB_TK error {yyerror ("']' expected"); RECOVER;};formal_parameter_list: formal_parameter { ctxp->formal_parameter_number = 1; }| formal_parameter_list C_TK formal_parameter { ctxp->formal_parameter_number += 1; $$ = chainon ($1, $3); }| formal_parameter_list C_TK error {yyerror ("Missing formal parameter term"); RECOVER;};formal_parameter: type variable_declarator_id { $$ = build_tree_list ($2, $1); }| modifiers type variable_declarator_id /* Added, JDK1.1 final parms */ { parse_jdk1_1_error ("final parameters"); $$ = build_tree_list ($3, $2); }| type error {yyerror ("Missing identifier"); RECOVER;}| modifiers type error { SOURCE_FRONTEND_DEBUG (("Modifiers: %d", $1)); yyerror ("Missing identifier"); RECOVER; };throws: { $$ = NULL_TREE; }| THROWS_TK class_type_list { $$ = $2; }| THROWS_TK error {yyerror ("Missing class type term"); RECOVER;};class_type_list: class_type { $$ = build_tree_list ($1, $1); }| class_type_list C_TK class_type { $$ = tree_cons ($3, $3, $1); }| class_type_list C_TK error {yyerror ("Missing class type term"); RECOVER;};method_body: block| block SC_TK| SC_TK { $$ = NULL_TREE; } /* Probably not the right thing to do. */;/* 19.8.4 Productions from 8.5: Static Initializers */static_initializer: static block { TREE_CHAIN ($2) = ctxp->static_initialized; ctxp->static_initialized = $2; }| static block SC_TK /* Shouldn't be here. FIXME */ { TREE_CHAIN ($2) = ctxp->static_initialized; ctxp->static_initialized = $2; };static: /* Test lval.sub_token here */ MODIFIER_TK { SOURCE_FRONTEND_DEBUG (("Modifiers: %d", $1)); };/* 19.8.5 Productions from 8.6: Constructor Declarations */constructor_declaration: constructor_header { current_function_decl = $1; source_start_java_method (current_function_decl); } constructor_body { finish_method_declaration ($3); };constructor_header: constructor_declarator throws { $$ = method_header (0, NULL_TREE, $1, $2); }| modifiers constructor_declarator throws { $$ = method_header ($1, NULL_TREE, $2, $3); };constructor_declarator: simple_name OP_TK CP_TK { $$ = method_declarator ($1, NULL_TREE); }| simple_name OP_TK formal_parameter_list CP_TK { $$ = method_declarator ($1, $3); };constructor_body: /* Unlike regular method, we always need a complete (empty) body so we can safely perform all the required code addition (super invocation and field initialization) */ block_begin constructor_block_end { BLOCK_EXPR_BODY ($2) = empty_stmt_node; $$ = $2; }| block_begin explicit_constructor_invocation constructor_block_end { $$ = $3; }| block_begin block_statements constructor_block_end { $$ = $3; }| block_begin explicit_constructor_invocation block_statements constructor_block_end { $$ = $4; };constructor_block_end: block_end| block_end SC_TK/* Error recovery for that rule moved down expression_statement: rule. */explicit_constructor_invocation: this_or_super OP_TK CP_TK SC_TK { $$ = build_method_invocation ($1, NULL_TREE); $$ = build_debugable_stmt (EXPR_WFL_LINECOL ($1), $$); $$ = java_method_add_stmt (current_function_decl, $$); }| this_or_super OP_TK argument_list CP_TK SC_TK { $$ = build_method_invocation ($1, $3); $$ = build_debugable_stmt (EXPR_WFL_LINECOL ($1), $$); $$ = java_method_add_stmt (current_function_decl, $$); } /* Added, JDK1.1 inner classes. Modified because the rule 'primary' couldn't work. */| name DOT_TK SUPER_TK OP_TK argument_list CP_TK SC_TK {$$ = parse_jdk1_1_error ("explicit constructor invocation"); }| name DOT_TK SUPER_TK OP_TK CP_TK SC_TK {$$ = parse_jdk1_1_error ("explicit constructor invocation"); };this_or_super: /* Added, simplifies error diagnostics */ THIS_TK { tree wfl = build_wfl_node (this_identifier_node); EXPR_WFL_LINECOL (wfl) = $1.location; $$ = wfl; }| SUPER_TK { tree wfl = build_wfl_node (super_identifier_node); EXPR_WFL_LINECOL (wfl) = $1.location; $$ = wfl; };/* 19.9 Productions from 9: Interfaces *//* 19.9.1 Productions from 9.1: Interfaces Declarations */interface_declaration: INTERFACE_TK identifier { create_interface (0, $2, NULL_TREE); } interface_body { $$ = $4; }| modifiers INTERFACE_TK identifier { create_interface ($1, $3, NULL_TREE); } interface_body { $$ = $5; }| INTERFACE_TK identifier extends_interfaces { create_interface (0, $2, $3); } interface_body { $$ = $5; }| modifiers INTERFACE_TK identifier extends_interfaces { create_interface ($1, $3, $4); } interface_body { $$ = $6; }| INTERFACE_TK identifier error {yyerror ("'{' expected"); RECOVER;}| modifiers INTERFACE_TK identifier error {yyerror ("'{' expected"); RECOVER;};extends_interfaces: EXTENDS_TK interface_type { ctxp->interface_number = 1; $$ = build_tree_list ($2, NULL_TREE); }| extends_interfaces C_TK interface_type { ctxp->interface_number++; $$ = chainon ($1, build_tree_list ($3, NULL_TREE)); }| EXTENDS_TK error {yyerror ("Invalid interface type"); RECOVER;}| extends_interfaces C_TK error {yyerror ("Missing term"); RECOVER;};interface_body: OCB_TK CCB_TK { $$ = NULL_TREE; }| OCB_TK interface_member_declarations CCB_TK { $$ = NULL_TREE; };interface_member_declarations: interface_member_declaration| interface_member_declarations interface_member_declaration;interface_member_declaration: constant_declaration| abstract_method_declaration| class_declaration /* Added, JDK1.1 inner classes */ { $$ = parse_jdk1_1_error ("inner class declaration"); }| interface_declaration /* Added, JDK1.1 inner classes */ { $$ = parse_jdk1_1_error ("inner interface declaration"); };constant_declaration: field_declaration;abstract_method_declaration: method_header SC_TK { check_abstract_method_header ($1); current_function_decl = NULL_TREE; /* FIXME ? */ }| method_header error {yyerror ("';' expected"); RECOVER;};/* 19.10 Productions from 10: Arrays */array_initializer: OCB_TK CCB_TK { $$ = build_new_array_init ($1.location, NULL_TREE); }| OCB_TK variable_initializers CCB_TK { $$ = build_new_array_init ($1.location, $2); }| OCB_TK variable_initializers C_TK CCB_TK { $$ = build_new_array_init ($1.location, $2); };variable_initializers: variable_initializer { $$ = tree_cons (maybe_build_array_element_wfl ($1), $1, NULL_TREE); }| variable_initializers C_TK variable_initializer { $$ = tree_cons (maybe_build_array_element_wfl ($3), $3, $1); }| variable_initializers C_TK error {yyerror ("Missing term"); RECOVER;};/* 19.11 Production from 14: Blocks and Statements */block: OCB_TK CCB_TK { /* Store the location of the `}' when doing xrefs */ if (current_function_decl && flag_emit_xref) DECL_END_SOURCE_LINE (current_function_decl) = EXPR_WFL_ADD_COL ($2.location, 1); $$ = empty_stmt_node; }| block_begin block_statements block_end { $$ = $3; };block_begin: OCB_TK { enter_block (); };block_end: CCB_TK { maybe_absorb_scoping_blocks (); /* Store the location of the `}' when doing xrefs */ if (current_function_decl && flag_emit_xref) DECL_END_SOURCE_LINE (current_function_decl) = EXPR_WFL_ADD_COL ($1.location, 1); $$ = exit_block (); };block_statements: block_statement| block_statements block_statement;block_statement: local_variable_declaration_statement| statement { java_method_add_stmt (current_function_decl, $1); }| class_declaration /* Added, JDK1.1 inner classes */ { parse_jdk1_1_error ("inner class declaration"); };local_variable_declaration_statement: local_variable_declaration SC_TK /* Can't catch missing ';' here */;local_variable_declaration: type variable_declarators { declare_local_variables (0, $1, $2); }| modifiers type variable_declarators /* Added, JDK1.1 final locals */ { declare_local_variables ($1, $2, $3); };statement: statement_without_trailing_substatement| labeled_statement| if_then_statement| if_then_else_statement| while_statement| for_statement { $$ = exit_block (); };statement_nsi: statement_without_trailing_substatement| labeled_statement_nsi| if_then_else_statement_nsi| while_statement_nsi| for_statement_nsi { $$ = exit_block (); };statement_without_trailing_substatement: block| empty_statement| expression_statement| switch_statement| do_statement| break_statement| continue_statement| return_statement| synchronized_statement| throw_statement| try_statement;empty_statement: SC_TK { $$ = empty_stmt_node; };label_decl: identifier REL_CL_TK { $$ = build_labeled_block (EXPR_WFL_LINECOL ($1), EXPR_WFL_NODE ($1)); pushlevel (2); push_labeled_block ($$); PUSH_LABELED_BLOCK ($$); };labeled_statement: label_decl statement { $$ = finish_labeled_statement ($1, $2); }| identifier error {yyerror ("':' expected"); RECOVER;};labeled_statement_nsi: label_decl statement_nsi { $$ = finish_labeled_statement ($1, $2); };/* We concentrate here a bunch of error handling rules that we couldn't write earlier, because expression_statement catches a missing ';'. */expression_statement: statement_expression SC_TK { /* We have a statement. Generate a WFL around it so we can debug it */ $$ = build_expr_wfl ($1, input_filename, lineno, 0); /* We know we have a statement, so set the debug info to be eventually generate here. */ $$ = JAVA_MAYBE_GENERATE_DEBUG_INFO ($$); }| error SC_TK { if (ctxp->prevent_ese != lineno) yyerror ("Invalid expression statement"); DRECOVER (expr_stmt); }| error OCB_TK { if (ctxp->prevent_ese != lineno) yyerror ("Invalid expression statement"); DRECOVER (expr_stmt); }| error CCB_TK { if (ctxp->prevent_ese != lineno) yyerror ("Invalid expression statement"); DRECOVER (expr_stmt); }| this_or_super OP_TK error {yyerror ("')' expected"); RECOVER;}| this_or_super OP_TK CP_TK error { yyerror ("Constructor invocation must be first " "thing in a constructor"); RECOVER; }| this_or_super OP_TK argument_list error {yyerror ("')' expected"); RECOVER;}| this_or_super OP_TK argument_list CP_TK error { yyerror ("Constructor invocation must be first " "thing in a constructor"); RECOVER; }| name DOT_TK SUPER_TK error {yyerror ("'(' expected"); RECOVER;}| name DOT_TK SUPER_TK OP_TK error {yyerror ("')' expected"); RECOVER;}| name DOT_TK SUPER_TK OP_TK argument_list error {yyerror ("')' expected"); RECOVER;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -