📄 cyacc.y
字号:
$$.value = build_component_ref (expr, $3); $$.original_code = ERROR_MARK; } | primary PLUSPLUS { $$.value = build_unary_op (POSTINCREMENT_EXPR, $1.value, 0); $$.original_code = ERROR_MARK; } | primary MINUSMINUS { $$.value = build_unary_op (POSTDECREMENT_EXPR, $1.value, 0); $$.original_code = ERROR_MARK; } ;/* This is the second argument to __builtin_offsetof. We must have one identifier, and beyond that we want to accept sub structure and sub array references. */offsetof_member_designator: identifier { $$ = build_component_ref (offsetof_base, $1); } | offsetof_member_designator '.' identifier { $$ = build_component_ref ($1, $3); } | offsetof_member_designator '[' expr ']' { $$ = build_array_ref ($1, $3.value); } ;old_style_parm_decls: /* empty */ | datadecls ;/* The following are analogous to lineno_decl, decls and decl except that they do not allow nested functions. They are used for old-style parm decls. */lineno_datadecl: save_location datadecl { } ;datadecls: lineno_datadecl | errstmt | datadecls lineno_datadecl | lineno_datadecl errstmt ;/* We don't allow prefix attributes here because they cause reduce/reduce conflicts: we can't know whether we're parsing a function decl with attribute suffix, or function defn with attribute prefix on first old style parm. */datadecl: declspecs_ts_nosa setspecs initdecls ';' { POP_DECLSPEC_STACK; } | declspecs_nots_nosa setspecs notype_initdecls ';' { POP_DECLSPEC_STACK; } | declspecs_ts_nosa ';' { shadow_tag_warned (finish_declspecs ($1), 1); pedwarn ("empty declaration"); } | declspecs_nots_nosa ';' { pedwarn ("empty declaration"); } ;/* This combination which saves a lineno before a decl is the normal thing to use, rather than decl itself. This is to avoid shift/reduce conflicts in contexts where statement labels are allowed. */lineno_decl: save_location decl { } ;/* records the type and storage class specs to use for processing the declarators that follow. Maintains a stack of outer-level values of current_declspecs, for the sake of parm declarations nested in function declarators. */setspecs: /* empty */ { pending_xref_error (); PUSH_DECLSPEC_STACK; if ($<dsptype>0) { prefix_attributes = $<dsptype>0->attrs; $<dsptype>0->attrs = NULL_TREE; current_declspecs = $<dsptype>0; } else { prefix_attributes = NULL_TREE; current_declspecs = build_null_declspecs (); } current_declspecs = finish_declspecs (current_declspecs); all_prefix_attributes = prefix_attributes; } ;/* Possibly attributes after a comma, which should reset all_prefix_attributes to prefix_attributes with these ones chained on the front. */maybe_resetattrs: maybe_attribute { all_prefix_attributes = chainon ($1, prefix_attributes); } ;decl: declspecs_ts setspecs initdecls ';' { POP_DECLSPEC_STACK; } | declspecs_nots setspecs notype_initdecls ';' { POP_DECLSPEC_STACK; } | declspecs_ts setspecs nested_function { POP_DECLSPEC_STACK; } | declspecs_nots setspecs notype_nested_function { POP_DECLSPEC_STACK; } | declspecs ';' { shadow_tag (finish_declspecs ($1)); } | extension decl { RESTORE_EXT_FLAGS ($1); } ;/* A list of declaration specifiers. These are: - Storage class specifiers (scspec), which for GCC currently includes function specifiers ("inline"). - Type specifiers (typespec_*). - Type qualifiers (TYPE_QUAL). - Attribute specifier lists (attributes). The various cases below are classified according to: (a) Whether a storage class specifier is included or not; some places in the grammar disallow storage class specifiers (_sc or _nosc). (b) Whether a type specifier has been seen; after a type specifier, a typedef name is an identifier to redeclare (_ts or _nots). (c) Whether the list starts with an attribute; in certain places, the grammar requires specifiers that don't start with an attribute (_sa or _nosa). (d) Whether the list ends with an attribute (or a specifier such that any following attribute would have been parsed as part of that specifier); this avoids shift-reduce conflicts in the parsing of attributes (_ea or _noea). TODO: (i) Distinguish between function specifiers and storage class specifiers, at least for the purpose of warnings about obsolescent usage. (ii) Halve the number of productions here by eliminating the _sc/_nosc distinction and instead checking where required that storage class specifiers aren't present. *//* Declspecs which contain at least one type specifier or typedef name. (Just `const' or `volatile' is not enough.) A typedef'd name following these is taken as a name to be declared. */declspecs_nosc_nots_nosa_noea: TYPE_QUAL { $$ = declspecs_add_qual (build_null_declspecs (), $1); } | declspecs_nosc_nots_nosa_noea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_nosc_nots_nosa_ea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } ;declspecs_nosc_nots_nosa_ea: declspecs_nosc_nots_nosa_noea attributes { $$ = declspecs_add_attrs ($1, $2); } ;declspecs_nosc_nots_sa_noea: declspecs_nosc_nots_sa_noea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_nosc_nots_sa_ea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } ;declspecs_nosc_nots_sa_ea: attributes { $$ = declspecs_add_attrs (build_null_declspecs (), $1); } | declspecs_nosc_nots_sa_noea attributes { $$ = declspecs_add_attrs ($1, $2); } ;declspecs_nosc_ts_nosa_noea: typespec_nonattr { $$ = declspecs_add_type (build_null_declspecs (), $1); } | declspecs_nosc_ts_nosa_noea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_nosc_ts_nosa_ea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_nots_nosa_noea typespec_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_nots_nosa_ea typespec_nonattr { $$ = declspecs_add_type ($1, $2); } ;declspecs_nosc_ts_nosa_ea: typespec_attr { $$ = declspecs_add_type (build_null_declspecs (), $1); } | declspecs_nosc_ts_nosa_noea attributes { $$ = declspecs_add_attrs ($1, $2); } | declspecs_nosc_ts_nosa_noea typespec_reserved_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_ts_nosa_ea typespec_reserved_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_nots_nosa_noea typespec_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_nots_nosa_ea typespec_attr { $$ = declspecs_add_type ($1, $2); } ;declspecs_nosc_ts_sa_noea: declspecs_nosc_ts_sa_noea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_nosc_ts_sa_ea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_nots_sa_noea typespec_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_nots_sa_ea typespec_nonattr { $$ = declspecs_add_type ($1, $2); } ;declspecs_nosc_ts_sa_ea: declspecs_nosc_ts_sa_noea attributes { $$ = declspecs_add_attrs ($1, $2); } | declspecs_nosc_ts_sa_noea typespec_reserved_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_ts_sa_ea typespec_reserved_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_nots_sa_noea typespec_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_nots_sa_ea typespec_attr { $$ = declspecs_add_type ($1, $2); } ;declspecs_sc_nots_nosa_noea: scspec { $$ = declspecs_add_scspec (build_null_declspecs (), $1); } | declspecs_sc_nots_nosa_noea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_sc_nots_nosa_ea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_nosc_nots_nosa_noea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_nosc_nots_nosa_ea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_sc_nots_nosa_noea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_sc_nots_nosa_ea scspec { $$ = declspecs_add_scspec ($1, $2); } ;declspecs_sc_nots_nosa_ea: declspecs_sc_nots_nosa_noea attributes { $$ = declspecs_add_attrs ($1, $2); } ;declspecs_sc_nots_sa_noea: declspecs_sc_nots_sa_noea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_sc_nots_sa_ea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_nosc_nots_sa_noea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_nosc_nots_sa_ea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_sc_nots_sa_noea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_sc_nots_sa_ea scspec { $$ = declspecs_add_scspec ($1, $2); } ;declspecs_sc_nots_sa_ea: declspecs_sc_nots_sa_noea attributes { $$ = declspecs_add_attrs ($1, $2); } ;declspecs_sc_ts_nosa_noea: declspecs_sc_ts_nosa_noea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_sc_ts_nosa_ea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_nots_nosa_noea typespec_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_nots_nosa_ea typespec_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_ts_nosa_noea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_nosc_ts_nosa_ea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_sc_ts_nosa_noea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_sc_ts_nosa_ea scspec { $$ = declspecs_add_scspec ($1, $2); } ;declspecs_sc_ts_nosa_ea: declspecs_sc_ts_nosa_noea attributes { $$ = declspecs_add_attrs ($1, $2); } | declspecs_sc_ts_nosa_noea typespec_reserved_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_ts_nosa_ea typespec_reserved_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_nots_nosa_noea typespec_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_nots_nosa_ea typespec_attr { $$ = declspecs_add_type ($1, $2); } ;declspecs_sc_ts_sa_noea: declspecs_sc_ts_sa_noea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_sc_ts_sa_ea TYPE_QUAL { $$ = declspecs_add_qual ($1, $2); } | declspecs_sc_ts_sa_noea typespec_reserved_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_ts_sa_ea typespec_reserved_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_nots_sa_noea typespec_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_nots_sa_ea typespec_nonattr { $$ = declspecs_add_type ($1, $2); } | declspecs_nosc_ts_sa_noea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_nosc_ts_sa_ea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_sc_ts_sa_noea scspec { $$ = declspecs_add_scspec ($1, $2); } | declspecs_sc_ts_sa_ea scspec { $$ = declspecs_add_scspec ($1, $2); } ;declspecs_sc_ts_sa_ea: declspecs_sc_ts_sa_noea attributes { $$ = declspecs_add_attrs ($1, $2); } | declspecs_sc_ts_sa_noea typespec_reserved_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_ts_sa_ea typespec_reserved_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_nots_sa_noea typespec_attr { $$ = declspecs_add_type ($1, $2); } | declspecs_sc_nots_sa_ea typespec_attr { $$ = declspecs_add_type ($1, $2); } ;/* Particular useful classes of declspecs. */declspecs_ts: declspecs_nosc_ts_nosa_noea | declspecs_nosc_ts_nosa_ea | declspecs_nosc_ts_sa_noea | declspecs_nosc_ts_sa_ea | declspecs_sc_ts_nosa_noea | declspecs_sc_ts_nosa_ea | declspecs_sc_ts_sa_noea | declspecs_sc_ts_sa_ea ;declspecs_nots: declspecs_nosc_nots_nosa_noea | declspecs_nosc_nots_nosa_ea | declspecs_nosc_nots_sa_noea | declspecs_nosc_nots_sa_ea | declspecs_sc_nots_nosa_noea | declspecs_sc_nots_nosa_ea | declspecs_sc_nots_sa_noea | declspecs_sc_nots_sa_ea ;declspecs_ts_nosa: declspecs_nosc_ts_nosa_noea | declspecs_nosc_ts_nosa_ea | declspecs_sc_ts_nosa_noea | declspecs_sc_ts_nosa_ea ;declspecs_nots_nosa: declspecs_nosc_nots_nosa_noea | declspecs_nosc_nots_nosa_ea | declspecs_sc_nots_nosa_noea | declspecs_sc_nots_nosa_ea ;declspecs_nosc_ts: declspecs_nosc_ts_nosa_noea | declspecs_nosc_ts_nosa_ea | declspecs_nosc_ts_sa_noea | declspecs_nosc_ts_sa_ea ;declspecs_nosc_nots: declspecs_nosc_nots_nosa_noea | declspecs_nosc_nots_nosa_ea | declspecs_nosc_nots_sa_noea | declspecs_nosc_nots_sa_ea ;declspecs_nosc: declspecs_nosc_ts_nosa_noea | declspecs_nosc_ts_nosa_ea | declspecs_nosc_ts_sa_noea | declspecs_nosc_ts_sa_ea | declspecs_nosc_nots_nosa_noea | declspecs_nosc_nots_nosa_ea | declspecs_nosc_nots_sa_noea | declspecs_nosc_nots_sa_ea ;declspecs: declspecs_nosc_nots_nosa_noea | declspecs_nosc_nots_nosa_ea | declspecs_nosc_nots_sa_noea | declspecs_nosc_nots_sa_ea | declspecs_nosc_ts_nosa_noea | declspecs_nosc_ts_nosa_ea | declspecs_nosc_ts_sa_noea | declspecs_nosc_ts_sa_ea | declspecs_sc_nots_nosa_noea | declspecs_sc_nots_nosa_ea | declspecs_sc_nots_sa_noea | declspecs_sc_nots_sa_ea | declspecs_sc_ts_nosa_noea | declspecs_sc_ts_nosa_ea | declspecs_sc_ts_sa_noea | declspecs_sc_ts_sa_ea ;/* A (possibly empty) sequence of type qualifiers and attributes. */maybe_type_quals_attrs: /* empty */ { $$ = NULL; } | declspecs_nosc_nots { $$ = $1; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -