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

📄 parse.y

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 Y
📖 第 1 页 / 共 5 页
字号:
%type	 <node>		IF_TK WHILE_TK FOR_TK%type    <node>         formal_parameter_list formal_parameter                        method_declarator method_header%type	 <node>		primitive_type reference_type type			BOOLEAN_TK INTEGRAL_TK FP_TK%%/* 19.2 Production from 2.3: The Syntactic Grammar  */goal:	compilation_unit		{};/* 19.3 Productions from 3: Lexical structure  */literal:	INT_LIT_TK|	FP_LIT_TK|	BOOL_LIT_TK|	CHAR_LIT_TK|       STRING_LIT_TK|       NULL_TK;/* 19.4 Productions from 4: Types, Values and Variables  */type:	primitive_type|	reference_type;primitive_type:	INTEGRAL_TK|	FP_TK|	BOOLEAN_TK;reference_type:	class_or_interface_type|	array_type;class_or_interface_type:	name;class_type:	class_or_interface_type	/* Default rule */;interface_type:	 class_or_interface_type;array_type:	primitive_type OSB_TK CSB_TK		{ 		  $$ = build_java_array_type ($1, -1);		  CLASS_LOADED_P ($$) = 1;		}|	name OSB_TK CSB_TK		{ $$ = build_unresolved_array_type ($1); }|	array_type OSB_TK CSB_TK		{ $$ = build_unresolved_array_type ($1); }|	primitive_type OSB_TK error		{RULE ("']' expected"); RECOVER;}|	array_type OSB_TK error		{RULE ("']' expected"); RECOVER;};/* 19.5 Productions from 6: Names  */name:	simple_name		/* Default rule */|	qualified_name		/* Default rule */;simple_name:	identifier		/* Default rule */;qualified_name:	name DOT_TK identifier		{ $$ = make_qualified_name ($1, $3, $2.location); };identifier:	ID_TK;/* 19.6: Production from 7: Packages  */compilation_unit:		{$$ = NULL;}|	package_declaration|	import_declarations|	type_declarations|       package_declaration import_declarations|       package_declaration type_declarations|       import_declarations type_declarations|       package_declaration import_declarations type_declarations;import_declarations:	import_declaration		{		  $$ = NULL;		}|	import_declarations import_declaration		{		  $$ = NULL;		};type_declarations:	type_declaration| 	type_declarations type_declaration;package_declaration:	PACKAGE_TK name SC_TK		{ ctxp->package = EXPR_WFL_NODE ($2); }|	PACKAGE_TK error		{yyerror ("Missing name"); RECOVER;}|	PACKAGE_TK name error		{yyerror ("';' expected"); RECOVER;};import_declaration:	single_type_import_declaration|	type_import_on_demand_declaration;single_type_import_declaration:	IMPORT_TK name SC_TK		{		  tree name = EXPR_WFL_NODE ($2), node, last_name;		  int   i = IDENTIFIER_LENGTH (name)-1;		  char *last = &IDENTIFIER_POINTER (name)[i];		  while (last != IDENTIFIER_POINTER (name))		    {		      if (last [0] == '.')			break;		      last--;		    }		  last_name = get_identifier (++last);		  if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))		    {		      tree err = find_name_in_single_imports (last_name);		      if (err && err != name)			parse_error_context			  ($2, "Ambiguous class: `%s' and `%s'",			   IDENTIFIER_POINTER (name), 			   IDENTIFIER_POINTER (err));		      else			REGISTER_IMPORT ($2, last_name)		    }		  else		    REGISTER_IMPORT ($2, last_name);		}|	IMPORT_TK error		{yyerror ("Missing name"); RECOVER;}|	IMPORT_TK name error		{yyerror ("';' expected"); RECOVER;};type_import_on_demand_declaration:	IMPORT_TK name DOT_TK MULT_TK SC_TK		{		  tree name = EXPR_WFL_NODE ($2);		  /* Don't import java.lang.* twice. */		  if (name != java_lang_id)		    {		      tree node = build_tree_list ($2, NULL_TREE);		      read_import_dir ($2);		      TREE_CHAIN (node) = ctxp->import_demand_list;		      ctxp->import_demand_list = node;		    }		}|	IMPORT_TK name DOT_TK error		{yyerror ("'*' expected"); RECOVER;}|	IMPORT_TK name DOT_TK MULT_TK error		{yyerror ("';' expected"); RECOVER;};type_declaration:	class_declaration		{		  maybe_generate_finit ();		  maybe_generate_clinit ();		  $$ = $1;		}|	interface_declaration		{		  maybe_generate_clinit ();		  $$ = $1;		}|	SC_TK		{ $$ = NULL; }|	error		{		  YYERROR_NOW;		  yyerror ("Class or interface declaration expected");		};/* 19.7 Shortened from the original:   modifiers: modifier | modifiers modifier   modifier: any of public...  */modifiers:	MODIFIER_TK		{		  $$ = (1 << $1);		}|	modifiers MODIFIER_TK		{		  int acc = (1 << $2);		  if ($$ & acc)		    parse_error_context 		      (ctxp->modifier_ctx [$2], "Modifier `%s' declared twice",		       java_accstring_lookup (acc));		  else		    {		      $$ |= acc;		    }		};/* 19.8.1 Production from $8.1: Class Declaration */class_declaration:	modifiers CLASS_TK identifier super interfaces		{ create_class ($1, $3, $4, $5); }	class_body		{ 		  $$ = $7;		}|	CLASS_TK identifier super interfaces 		{ create_class (0, $2, $3, $4); }	class_body		{ 			  $$ = $6;		}|	modifiers CLASS_TK error		{yyerror ("Missing class name"); RECOVER;}|	CLASS_TK error		{yyerror ("Missing class name"); RECOVER;}|       CLASS_TK identifier error		{		  if (!ctxp->class_err) yyerror ("'{' expected"); 		  DRECOVER(class1);		}|       modifiers CLASS_TK identifier error		{if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;};super:		{ $$ = NULL; }|	EXTENDS_TK class_type		{ $$ = $2; }|	EXTENDS_TK class_type error		{yyerror ("'{' expected"); ctxp->class_err=1;}|	EXTENDS_TK error		{yyerror ("Missing super class name"); ctxp->class_err=1;};interfaces:		{ $$ = NULL_TREE; }|	IMPLEMENTS_TK interface_type_list		{ $$ = $2; }|	IMPLEMENTS_TK error		{		  ctxp->class_err=1;		  yyerror ("Missing interface name"); 		};interface_type_list:	interface_type		{ 		  ctxp->interface_number = 1;		  $$ = build_tree_list ($1, NULL_TREE);		}|	interface_type_list C_TK interface_type		{ 		  ctxp->interface_number++;		  $$ = chainon ($1, build_tree_list ($3, NULL_TREE));		}|	interface_type_list C_TK error		{yyerror ("Missing interface name"); RECOVER;};class_body:	OCB_TK CCB_TK		{ 		  /* Store the location of the `}' when doing xrefs */		  if (flag_emit_xref)		    DECL_END_SOURCE_LINE (ctxp->current_parsed_class) = 		      EXPR_WFL_ADD_COL ($2.location, 1);		  $$ = ctxp->current_parsed_class;		}|	OCB_TK class_body_declarations CCB_TK		{ 		  /* Store the location of the `}' when doing xrefs */		  if (flag_emit_xref)		    DECL_END_SOURCE_LINE (ctxp->current_parsed_class) = 		      EXPR_WFL_ADD_COL ($3.location, 1);		  $$ = ctxp->current_parsed_class;		};class_body_declarations:	class_body_declaration|	class_body_declarations class_body_declaration;class_body_declaration:	class_member_declaration|	static_initializer|	constructor_declaration|	block			/* Added, JDK1.1, instance initializer */		{ $$ = parse_jdk1_1_error ("instance initializer"); };class_member_declaration:	field_declaration|	field_declaration SC_TK		{ $$ = $1; }|	method_declaration|	class_declaration	/* Added, JDK1.1 inner classes */		{ $$ = parse_jdk1_1_error ("inner classe declaration"); }|	interface_declaration	/* Added, JDK1.1 inner classes */		{ $$ = parse_jdk1_1_error ("inner interface declaration"); };/* 19.8.2 Productions from 8.3: Field Declarations  */field_declaration:	type variable_declarators SC_TK		{ register_fields (0, $1, $2); }|	modifiers type variable_declarators SC_TK		{		  check_modifiers 		    ("Illegal modifier `%s' for field declaration",		     $1, FIELD_MODIFIERS);		  check_modifiers_consistency ($1);		  register_fields ($1, $2, $3);		};variable_declarators:	/* Should we use build_decl_list () instead ? FIXME */	variable_declarator	/* Default rule */|	variable_declarators C_TK variable_declarator		{ $$ = chainon ($1, $3); }|	variable_declarators C_TK error		{yyerror ("Missing term"); RECOVER;};variable_declarator:	variable_declarator_id		{ $$ = build_tree_list ($1, NULL_TREE); }|	variable_declarator_id ASSIGN_TK variable_initializer		{ 		  if (java_error_count)		    $3 = NULL_TREE;		  $$ = build_tree_list 		    ($1, build_assignment ($2.token, $2.location, $1, $3));		}|	variable_declarator_id ASSIGN_TK error		{		  yyerror ("Missing variable initializer");		  $$ = build_tree_list ($1, NULL_TREE);		  RECOVER;		}|	variable_declarator_id ASSIGN_TK variable_initializer error		{		  yyerror ("';' expected");		  $$ = build_tree_list ($1, NULL_TREE);		  RECOVER;		};variable_declarator_id:	identifier|	variable_declarator_id OSB_TK CSB_TK		{ $$ = build_unresolved_array_type ($1); }|	identifier error		{yyerror ("Invalid declaration"); DRECOVER(vdi);}|	variable_declarator_id OSB_TK error		{yyerror ("']' expected"); DRECOVER(vdi);}|	variable_declarator_id CSB_TK error		{yyerror ("Unbalanced ']'"); DRECOVER(vdi);};variable_initializer:	expression|	array_initializer;/* 19.8.3 Productions from 8.4: Method Declarations  */method_declaration:	method_header 		{		  current_function_decl = $1;		  source_start_java_method (current_function_decl);		}	method_body		{ finish_method_declaration ($3); }|	method_header error		{YYNOT_TWICE yyerror ("'{' expected"); RECOVER;};method_header:		type method_declarator throws		{ $$ = method_header (0, $1, $2, $3); }|	VOID_TK method_declarator throws		{ $$ = method_header (0, void_type_node, $2, $3); }|	modifiers type method_declarator throws		{ $$ = method_header ($1, $2, $3, $4); }|	modifiers VOID_TK method_declarator throws		{ $$ = method_header ($1, void_type_node, $3, $4); }|	type error		{RECOVER;}|	modifiers type error		{RECOVER;}|	VOID_TK error		{yyerror ("Identifier expected"); RECOVER;}|	modifiers VOID_TK error		{yyerror ("Identifier expected"); RECOVER;}|	modifiers error		{		  yyerror ("Invalid method declaration, return type required");		  RECOVER;		};method_declarator:	identifier OP_TK CP_TK		{ $$ = method_declarator ($1, NULL_TREE); }|	identifier OP_TK formal_parameter_list CP_TK		{ $$ = method_declarator ($1, $3); }|	method_declarator OSB_TK CSB_TK		{		  EXPR_WFL_LINECOL (wfl_operator) = $2.location;		  TREE_PURPOSE ($1) = 		    build_unresolved_array_type (TREE_PURPOSE ($1));		  parse_warning_context 		    (wfl_operator, 

⌨️ 快捷键说明

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