📄 parse-scan.y
字号:
| abstract_method_declaration| class_declaration /* Added, JDK1.1 inner classes */| interface_declaration /* Added, JDK1.1 inner classes */;constant_declaration: field_declaration;abstract_method_declaration: method_header SC_TK;/* 19.10 Productions from 10: Arrays */array_initializer: OCB_TK CCB_TK| OCB_TK variable_initializers CCB_TK| OCB_TK C_TK CCB_TK| OCB_TK variable_initializers C_TK CCB_TK;variable_initializers: variable_initializer| variable_initializers C_TK variable_initializer;/* 19.11 Production from 14: Blocks and Statements */block: OCB_TK CCB_TK| OCB_TK block_statements CCB_TK;block_statements: block_statement| block_statements block_statement;block_statement: local_variable_declaration_statement| statement| class_declaration /* Added, JDK1.1 inner classes */;local_variable_declaration_statement: local_variable_declaration SC_TK /* Can't catch missing ';' here */;local_variable_declaration: type variable_declarators { USE_ABSORBER; }| modifiers type variable_declarators /* Added, JDK1.1 final locals */ { modifier_value = 0; };statement: statement_without_trailing_substatement| labeled_statement| if_then_statement| if_then_else_statement| while_statement| for_statement;statement_nsi: statement_without_trailing_substatement| labeled_statement_nsi| if_then_else_statement_nsi| while_statement_nsi| for_statement_nsi;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;label_decl: identifier REL_CL_TK { USE_ABSORBER; };labeled_statement: label_decl statement;labeled_statement_nsi: label_decl statement_nsi;/* 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;statement_expression: assignment| pre_increment_expression| pre_decrement_expression| post_increment_expression| post_decrement_expression| method_invocation| class_instance_creation_expression;if_then_statement: IF_TK OP_TK expression CP_TK statement;if_then_else_statement: IF_TK OP_TK expression CP_TK statement_nsi ELSE_TK statement;if_then_else_statement_nsi: IF_TK OP_TK expression CP_TK statement_nsi ELSE_TK statement_nsi;switch_statement: SWITCH_TK OP_TK expression CP_TK switch_block;switch_block: OCB_TK CCB_TK| OCB_TK switch_labels CCB_TK| OCB_TK switch_block_statement_groups CCB_TK| OCB_TK switch_block_statement_groups switch_labels CCB_TK;switch_block_statement_groups: switch_block_statement_group| switch_block_statement_groups switch_block_statement_group;switch_block_statement_group: switch_labels block_statements;switch_labels: switch_label| switch_labels switch_label;switch_label: CASE_TK constant_expression REL_CL_TK| DEFAULT_TK REL_CL_TK;while_expression: WHILE_TK OP_TK expression CP_TK;while_statement: while_expression statement;while_statement_nsi: while_expression statement_nsi;do_statement_begin: DO_TK;do_statement: do_statement_begin statement WHILE_TK OP_TK expression CP_TK SC_TK;for_statement: for_begin SC_TK expression SC_TK for_update CP_TK statement| for_begin SC_TK SC_TK for_update CP_TK statement;for_statement_nsi: for_begin SC_TK expression SC_TK for_update CP_TK statement_nsi| for_begin SC_TK SC_TK for_update CP_TK statement_nsi;for_header: FOR_TK OP_TK;for_begin: for_header for_init;for_init: /* Can be empty */| statement_expression_list| local_variable_declaration;for_update: /* Can be empty */| statement_expression_list;statement_expression_list: statement_expression| statement_expression_list C_TK statement_expression;break_statement: BREAK_TK SC_TK| BREAK_TK identifier SC_TK;continue_statement: CONTINUE_TK SC_TK| CONTINUE_TK identifier SC_TK;return_statement: RETURN_TK SC_TK| RETURN_TK expression SC_TK;throw_statement: THROW_TK expression SC_TK;synchronized_statement: synchronized OP_TK expression CP_TK block| synchronized OP_TK expression CP_TK error;synchronized: /* Test lval.sub_token here */ MODIFIER_TK { USE_ABSORBER; };try_statement: TRY_TK block catches| TRY_TK block finally| TRY_TK block catches finally;catches: catch_clause| catches catch_clause;catch_clause: CATCH_TK OP_TK formal_parameter CP_TK block;finally: FINALLY_TK block;/* 19.12 Production from 15: Expressions */primary: primary_no_new_array| array_creation_expression;primary_no_new_array: literal| THIS_TK| OP_TK expression CP_TK| class_instance_creation_expression| field_access| method_invocation| array_access /* type DOT_TK CLASS_TK doens't work. So we split the rule 'type' into its components. Missing is something for array, which will complete the reference_type part. FIXME */| name DOT_TK CLASS_TK /* Added, JDK1.1 class literals */ { USE_ABSORBER; }| primitive_type DOT_TK CLASS_TK /* Added, JDK1.1 class literals */ { USE_ABSORBER; }| VOID_TK DOT_TK CLASS_TK /* Added, JDK1.1 class literals */ /* Added, JDK1.1 inner classes. Documentation is wrong refering to a 'ClassName' (class_name) rule that doesn't exist. Used name instead. */| name DOT_TK THIS_TK { USE_ABSORBER; };class_instance_creation_expression: NEW_TK class_type OP_TK argument_list CP_TK| NEW_TK class_type OP_TK CP_TK /* Added, JDK1.1 inner classes but modified to use 'class_type' instead of 'TypeName' (type_name) mentionned in the documentation but doesn't exist. */| NEW_TK class_type OP_TK argument_list CP_TK class_body| NEW_TK class_type OP_TK CP_TK class_body /* Added, JDK1.1 inner classes, modified to use name or primary instead of primary solely which couldn't work in all situations. */| something_dot_new identifier OP_TK CP_TK| something_dot_new identifier OP_TK CP_TK class_body| something_dot_new identifier OP_TK argument_list CP_TK| something_dot_new identifier OP_TK argument_list CP_TK class_body;something_dot_new: /* Added, not part of the specs. */ name DOT_TK NEW_TK { USE_ABSORBER; }| primary DOT_TK NEW_TK;argument_list: expression| argument_list C_TK expression| argument_list C_TK error;array_creation_expression: NEW_TK primitive_type dim_exprs| NEW_TK class_or_interface_type dim_exprs| NEW_TK primitive_type dim_exprs dims| NEW_TK class_or_interface_type dim_exprs dims /* Added, JDK1.1 anonymous array. Initial documentation rule modified */| NEW_TK class_or_interface_type dims array_initializer| NEW_TK primitive_type dims array_initializer;dim_exprs: dim_expr| dim_exprs dim_expr;dim_expr: OSB_TK expression CSB_TK;dims: OSB_TK CSB_TK| dims OSB_TK CSB_TK;field_access: primary DOT_TK identifier| SUPER_TK DOT_TK identifier;method_invocation: name OP_TK CP_TK { USE_ABSORBER; }| name OP_TK argument_list CP_TK { USE_ABSORBER; }| primary DOT_TK identifier OP_TK CP_TK| primary DOT_TK identifier OP_TK argument_list CP_TK| SUPER_TK DOT_TK identifier OP_TK CP_TK| SUPER_TK DOT_TK identifier OP_TK argument_list CP_TK;array_access: name OSB_TK expression CSB_TK { USE_ABSORBER; }| primary_no_new_array OSB_TK expression CSB_TK;postfix_expression: primary| name { USE_ABSORBER; }| post_increment_expression| post_decrement_expression;post_increment_expression: postfix_expression INCR_TK;post_decrement_expression: postfix_expression DECR_TK;unary_expression: pre_increment_expression| pre_decrement_expression| PLUS_TK unary_expression| MINUS_TK unary_expression| unary_expression_not_plus_minus;pre_increment_expression: INCR_TK unary_expression;pre_decrement_expression: DECR_TK unary_expression;unary_expression_not_plus_minus: postfix_expression| NOT_TK unary_expression| NEG_TK unary_expression| cast_expression;cast_expression: /* Error handling here is potentially weak */ OP_TK primitive_type dims CP_TK unary_expression| OP_TK primitive_type CP_TK unary_expression| OP_TK expression CP_TK unary_expression_not_plus_minus| OP_TK name dims CP_TK unary_expression_not_plus_minus;multiplicative_expression: unary_expression| multiplicative_expression MULT_TK unary_expression| multiplicative_expression DIV_TK unary_expression| multiplicative_expression REM_TK unary_expression;additive_expression: multiplicative_expression| additive_expression PLUS_TK multiplicative_expression| additive_expression MINUS_TK multiplicative_expression;shift_expression: additive_expression| shift_expression LS_TK additive_expression| shift_expression SRS_TK additive_expression| shift_expression ZRS_TK additive_expression;relational_expression: shift_expression| relational_expression LT_TK shift_expression| relational_expression GT_TK shift_expression| relational_expression LTE_TK shift_expression| relational_expression GTE_TK shift_expression| relational_expression INSTANCEOF_TK reference_type;equality_expression: relational_expression| equality_expression EQ_TK relational_expression| equality_expression NEQ_TK relational_expression;and_expression: equality_expression| and_expression AND_TK equality_expression;exclusive_or_expression: and_expression| exclusive_or_expression XOR_TK and_expression;inclusive_or_expression: exclusive_or_expression| inclusive_or_expression OR_TK exclusive_or_expression;conditional_and_expression: inclusive_or_expression| conditional_and_expression BOOL_AND_TK inclusive_or_expression;conditional_or_expression: conditional_and_expression| conditional_or_expression BOOL_OR_TK conditional_and_expression;conditional_expression: /* Error handling here is weak */ conditional_or_expression| conditional_or_expression REL_QM_TK expression REL_CL_TK conditional_expression;assignment_expression: conditional_expression| assignment;assignment: left_hand_side assignment_operator assignment_expression;left_hand_side: name { USE_ABSORBER; }| field_access| array_access;assignment_operator: ASSIGN_ANY_TK| ASSIGN_TK;expression: assignment_expression;constant_expression: expression;%%#include "lex.c"/* Create a new parser context */voidjava_push_parser_context (){ struct parser_ctxt *new = (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt)); bzero ((PTR) new, sizeof (struct parser_ctxt)); new->next = ctxp; ctxp = new;} /* Actions defined here */static voidreport_class_declaration (name) char * name;{ extern int flag_dump_class, flag_list_filename; if (flag_dump_class) { if (!previous_output) { if (flag_list_filename) fprintf (out, "%s: ", input_filename); previous_output = 1; } if (package_name) fprintf (out, "%s.%s ", package_name, name); else fprintf (out, "%s ", name); } current_class = name;}static voidreport_main_declaration (declarator) struct method_declarator *declarator;{ extern int flag_find_main; if (flag_find_main && modifier_value == 2 && !strcmp (declarator->method_name, "main") && declarator->args && declarator->args [0] == '[' && (! strcmp (declarator->args+1, "String") || ! strcmp (declarator->args + 1, "java.lang.String")) && current_class) { if (!previous_output) { if (package_name) fprintf (out, "%s.%s ", package_name, current_class); else fprintf (out, current_class); previous_output = 1; } }}/* Reset global status used by the report functions. */void reset_report (){ previous_output = 0; current_class = package_name = NULL;}voidyyerror (msg) char *msg ATTRIBUTE_UNUSED;{}char *xstrdup (s) const char *s;{ char *ret; ret = xmalloc (strlen (s) + 1); strcpy (ret, s); return ret;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -