Changeset 5407cdc for src/Parser/parser.yy
- Timestamp:
- Apr 28, 2021, 4:56:50 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8d66610
- Parents:
- feacef9 (diff), b7fd2db6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rfeacef9 r5407cdc 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 3 18:30:12202113 // Update Count : 4 70012 // Last Modified On : Mon Apr 26 18:41:54 2021 13 // Update Count : 4990 14 14 // 15 15 … … 32 32 // 33 33 // 1. designation with and without '=' (use ':' instead) 34 // 2. attributes not allowed in parenthesis of declarator 34 35 35 // 36 36 // All of the syntactic extensions for GCC C are marked with the comment "GCC". The second extensions are for Cforall … … 211 211 } // forCtrl 212 212 213 bool forall = false , yyy = false;// aggregate have one or more forall qualifiers ?213 bool forall = false; // aggregate have one or more forall qualifiers ? 214 214 215 215 // https://www.gnu.org/software/bison/manual/bison.html#Location-Type … … 264 264 %token RESTRICT // C99 265 265 %token ATOMIC // C11 266 %token FORALL MUTEX VIRTUAL COERCE// CFA266 %token FORALL MUTEX VIRTUAL VTABLE COERCE // CFA 267 267 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 268 268 %token BOOL COMPLEX IMAGINARY // C99 … … 270 270 %token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC 271 271 %token ZERO_T ONE_T // CFA 272 %token VALIST // GCC 273 %token AUTO_TYPE // GCC 274 %token TYPEOF BASETYPEOF LABEL // GCC 272 %token SIZEOF TYPEOF VALIST AUTO_TYPE // GCC 273 %token OFFSETOF BASETYPEOF TYPEID // CFA 275 274 %token ENUM STRUCT UNION 276 275 %token EXCEPTION // CFA 277 276 %token GENERATOR COROUTINE MONITOR THREAD // CFA 278 277 %token OTYPE FTYPE DTYPE TTYPE TRAIT // CFA 279 %token SIZEOF OFFSETOF280 278 // %token RESUME // CFA 279 %token LABEL // GCC 281 280 %token SUSPEND // CFA 282 281 %token ATTRIBUTE EXTENSION // GCC 283 282 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 284 %token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGH TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA 283 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR // CFA 284 %token DISABLE ENABLE TRY THROW THROWRESUME AT // CFA 285 285 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 286 286 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 287 287 288 288 // names and constants: lexer differentiates between identifier and typedef names 289 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFnameTYPEGENname290 %token<tok> TIMEOUT WOR291 %token<tok> INTEGERconstant CHARACTERconstantSTRINGliteral289 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFname TYPEGENname 290 %token<tok> TIMEOUT WOR CATCH RECOVER CATCHRESUME FIXUP FINALLY // CFA 291 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 292 292 %token<tok> DIRECTIVE 293 293 // Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and … … 321 321 %type<en> constant 322 322 %type<en> tuple tuple_expression_list 323 %type<op> ptrref_operator unary_operator assignment_operator 323 %type<op> ptrref_operator unary_operator assignment_operator simple_assignment_operator compound_assignment_operator 324 324 %type<en> primary_expression postfix_expression unary_expression 325 325 %type<en> cast_expression_list cast_expression exponential_expression multiplicative_expression additive_expression … … 373 373 374 374 %type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type 375 %type<decl> vtable vtable_opt default_opt 375 376 376 377 %type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier … … 428 429 429 430 %type<decl> type_declaration_specifier type_type_specifier type_name typegen_name 430 %type<decl> typedef typedef_declaration typedef_expression431 %type<decl> typedef_name typedef_declaration typedef_expression 431 432 432 433 %type<decl> variable_type_redeclarator type_ptr type_array type_function … … 440 441 441 442 %type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list 442 %type<decl> type_specifier type_specifier_nobody enum_specifier_nobody443 %type<decl> type_specifier type_specifier_nobody 443 444 444 445 %type<decl> variable_declarator variable_ptr variable_array variable_function 445 446 %type<decl> variable_abstract_declarator variable_abstract_ptr variable_abstract_array variable_abstract_function 446 447 447 %type<decl> attribute_list_opt attribute_list attribute _opt attributeattribute_name_list attribute_name448 %type<decl> attribute_list_opt attribute_list attribute attribute_name_list attribute_name 448 449 449 450 // initializers … … 462 463 // Order of these lines matters (low-to-high precedence). THEN is left associative over WOR/TIMEOUT/ELSE, WOR is left 463 464 // associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE. 464 %precedence THEN // rule precedence for IF/WAITFOR statement 465 %precedence WOR // token precedence for start of WOR in WAITFOR statement 466 %precedence TIMEOUT // token precedence for start of TIMEOUT in WAITFOR statement 467 %precedence ELSE // token precedence for start of else clause in IF/WAITFOR statement 465 %precedence THEN // rule precedence for IF/WAITFOR statement 466 %precedence WOR // token precedence for start of WOR in WAITFOR statement 467 %precedence TIMEOUT // token precedence for start of TIMEOUT in WAITFOR statement 468 %precedence CATCH // token precedence for start of TIMEOUT in WAITFOR statement 469 %precedence RECOVER // token precedence for start of TIMEOUT in WAITFOR statement 470 %precedence CATCHRESUME // token precedence for start of TIMEOUT in WAITFOR statement 471 %precedence FIXUP // token precedence for start of TIMEOUT in WAITFOR statement 472 %precedence FINALLY // token precedence for start of TIMEOUT in WAITFOR statement 473 %precedence ELSE // token precedence for start of else clause in IF/WAITFOR statement 474 468 475 469 476 // Handle shift/reduce conflict for generic type by shifting the '(' token. For example, this string is ambiguous: … … 544 551 TIMEOUT 545 552 | WOR 553 | CATCH 554 | RECOVER 555 | CATCHRESUME 556 | FIXUP 557 | FINALLY 546 558 ; 547 559 … … 774 786 | OFFSETOF '(' type_no_function ',' identifier ')' 775 787 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 788 | TYPEID '(' type_no_function ')' 789 { 790 SemanticError( yylloc, "typeid name is currently unimplemented." ); $$ = nullptr; 791 // $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); 792 } 776 793 ; 777 794 … … 795 812 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 796 813 | '(' aggregate_control '&' ')' cast_expression // CFA 814 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 815 | '(' aggregate_control '*' ')' cast_expression // CFA 797 816 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 798 817 | '(' VIRTUAL ')' cast_expression // CFA … … 939 958 940 959 assignment_operator: 960 simple_assignment_operator 961 | compound_assignment_operator 962 ; 963 964 simple_assignment_operator: 941 965 '=' { $$ = OperKinds::Assign; } 942 | ATassign { $$ = OperKinds::AtAssn; } 943 | EXPassign { $$ = OperKinds::ExpAssn; } 966 | ATassign { $$ = OperKinds::AtAssn; } // CFA 967 ; 968 969 compound_assignment_operator: 970 EXPassign { $$ = OperKinds::ExpAssn; } 944 971 | MULTassign { $$ = OperKinds::MulAssn; } 945 972 | DIVassign { $$ = OperKinds::DivAssn; } … … 1019 1046 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); } 1020 1047 | '{' push 1021 local_label_declaration_opt // GCC, local labels 1048 local_label_declaration_opt // GCC, local labels appear at start of block 1022 1049 statement_decl_list // C99, intermix declarations and statements 1023 1050 pop '}' … … 1217 1244 | comma_expression ';' comma_expression inclexcl comma_expression '~' comma_expression // CFA 1218 1245 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); } 1246 1247 | comma_expression ';' TYPEDEFname // CFA, array type 1248 { 1249 SemanticError( yylloc, "Array interator is currently unimplemented." ); $$ = nullptr; 1250 $$ = forCtrl( new ExpressionNode( build_varref( $3 ) ), $1, nullptr, OperKinds::Range, nullptr, nullptr ); 1251 } 1219 1252 1220 1253 // There is a S/R conflicit if ~ and -~ are factored out. … … 1366 1399 1367 1400 exception_statement: 1368 TRY compound_statement handler_clause 1401 TRY compound_statement handler_clause %prec THEN 1369 1402 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 1370 1403 | TRY compound_statement finally_clause … … 1389 1422 handler_key: 1390 1423 CATCH { $$ = CatchStmt::Terminate; } 1424 | RECOVER { $$ = CatchStmt::Terminate; } 1391 1425 | CATCHRESUME { $$ = CatchStmt::Resume; } 1426 | FIXUP { $$ = CatchStmt::Resume; } 1392 1427 ; 1393 1428 … … 1741 1776 ; 1742 1777 1743 enum_specifier_nobody: // type specifier - {...}1744 // Preclude SUE declarations in restricted scopes (see type_specifier_nobody)1745 basic_type_specifier1746 | sue_type_specifier_nobody1747 ;1748 1749 1778 type_qualifier_list_opt: // GCC, used in asm_statement 1750 1779 // empty … … 1766 1795 type_qualifier: 1767 1796 type_qualifier_name 1768 | attribute 1797 | attribute // trick handles most atrribute locations 1769 1798 ; 1770 1799 … … 1874 1903 | AUTO_TYPE 1875 1904 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); } 1905 | vtable 1906 ; 1907 1908 vtable_opt: 1909 // empty 1910 { $$ = nullptr; } 1911 | vtable; 1912 ; 1913 1914 vtable: 1915 VTABLE '(' type_list ')' default_opt 1916 { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; } 1917 ; 1918 1919 default_opt: 1920 // empty 1921 { $$ = nullptr; } 1922 | DEFAULT 1923 { SemanticError( yylloc, "vtable default is currently unimplemented." ); $$ = nullptr; } 1876 1924 ; 1877 1925 … … 2025 2073 '{' field_declaration_list_opt '}' type_parameters_opt 2026 2074 { $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); } 2027 | aggregate_key attribute_list_opt type_name 2028 { 2029 // for type_name can be a qualified type name S.T, in which case only the last name in the chain needs a typedef (other names in the chain should already have one) 2030 typedefTable.makeTypedef( *$3->type->leafName(), forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef 2075 | aggregate_key attribute_list_opt TYPEDEFname // unqualified type name 2076 { 2077 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef 2031 2078 forall = false; // reset 2032 2079 } 2033 2080 '{' field_declaration_list_opt '}' type_parameters_opt 2034 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $8, $6, true )->addQualifiers( $2 ); } 2081 { 2082 DeclarationNode::newFromTypedef( $3 ); 2083 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); 2084 } 2085 | aggregate_key attribute_list_opt TYPEGENname // unqualified type name 2086 { 2087 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef 2088 forall = false; // reset 2089 } 2090 '{' field_declaration_list_opt '}' type_parameters_opt 2091 { 2092 DeclarationNode::newFromTypeGen( $3, nullptr ); 2093 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); 2094 } 2035 2095 | aggregate_type_nobody 2036 2096 ; … … 2069 2129 2070 2130 aggregate_data: 2071 STRUCT 2072 { yyy = true;$$ = AggregateDecl::Struct; }2131 STRUCT vtable_opt 2132 { $$ = AggregateDecl::Struct; } 2073 2133 | UNION 2074 { yyy = true;$$ = AggregateDecl::Union; }2134 { $$ = AggregateDecl::Union; } 2075 2135 | EXCEPTION // CFA 2076 // { yyy = true;$$ = AggregateDecl::Exception; }2077 { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }2136 { $$ = AggregateDecl::Exception; } 2137 // { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2078 2138 ; 2079 2139 2080 2140 aggregate_control: // CFA 2081 2141 MONITOR 2082 { yyy = true;$$ = AggregateDecl::Monitor; }2142 { $$ = AggregateDecl::Monitor; } 2083 2143 | MUTEX STRUCT 2084 { yyy = true;$$ = AggregateDecl::Monitor; }2144 { $$ = AggregateDecl::Monitor; } 2085 2145 | GENERATOR 2086 { yyy = true;$$ = AggregateDecl::Generator; }2146 { $$ = AggregateDecl::Generator; } 2087 2147 | MUTEX GENERATOR 2088 2148 { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2089 2149 | COROUTINE 2090 { yyy = true;$$ = AggregateDecl::Coroutine; }2150 { $$ = AggregateDecl::Coroutine; } 2091 2151 | MUTEX COROUTINE 2092 2152 { SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2093 2153 | THREAD 2094 { yyy = true;$$ = AggregateDecl::Thread; }2154 { $$ = AggregateDecl::Thread; } 2095 2155 | MUTEX THREAD 2096 2156 { SemanticError( yylloc, "monitor thread is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } … … 2188 2248 ; 2189 2249 2190 // Cannot use attribute_list_opt because of ambiguity with enum_specifier_nobody, which already parses attribute.2191 // Hence, only a single attribute is allowed after the "ENUM".2192 2250 enum_type: // enum 2193 ENUM attribute_ opt '{' enumerator_list comma_opt '}'2251 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2194 2252 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 2195 | ENUM attribute_ opt identifier2253 | ENUM attribute_list_opt identifier 2196 2254 { typedefTable.makeTypedef( *$3 ); } 2197 2255 '{' enumerator_list comma_opt '}' 2198 2256 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); } 2199 | ENUM attribute_ opt typedef // enum cannot be generic2257 | ENUM attribute_list_opt typedef_name // unqualified type name 2200 2258 '{' enumerator_list comma_opt '}' 2201 2259 { $$ = DeclarationNode::newEnum( $3->name, $5, true )->addQualifiers( $2 ); } 2202 | ENUM enum_specifier_nobody '{' enumerator_list comma_opt '}' 2203 // { $$ = DeclarationNode::newEnum( nullptr, $4, true ); } 2204 { SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; } 2205 | ENUM enum_specifier_nobody declarator '{' enumerator_list comma_opt '}' 2206 // { 2207 // typedefTable.makeTypedef( *$3->name ); 2208 // $$ = DeclarationNode::newEnum( nullptr, $5, true ); 2209 // } 2210 { SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; } 2260 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}' 2261 { 2262 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2263 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2264 } 2265 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2266 { 2267 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2268 typedefTable.makeTypedef( *$6 ); 2269 } 2270 '{' enumerator_list comma_opt '}' 2271 { 2272 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2273 } 2274 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' 2275 { 2276 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2277 typedefTable.makeTypedef( *$6->name ); 2278 SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2279 } 2211 2280 | enum_type_nobody 2212 2281 ; 2213 2282 2214 2283 enum_type_nobody: // enum - {...} 2215 ENUM attribute_opt identifier 2216 { 2217 typedefTable.makeTypedef( *$3 ); 2218 $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); 2219 } 2220 | ENUM attribute_opt type_name // enum cannot be generic 2221 { 2222 typedefTable.makeTypedef( *$3->type->symbolic.name ); 2223 $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false )->addQualifiers( $2 ); 2224 } 2284 ENUM attribute_list_opt identifier 2285 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); } 2286 | ENUM attribute_list_opt type_name // qualified type name 2287 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false )->addQualifiers( $2 ); } 2225 2288 ; 2226 2289 … … 2228 2291 identifier_or_type_name enumerator_value_opt 2229 2292 { $$ = DeclarationNode::newEnumConstant( $1, $2 ); } 2293 | INLINE type_name 2294 { $$ = DeclarationNode::newEnumConstant( new string("inline"), nullptr ); } 2230 2295 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2231 2296 { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); } 2297 | enumerator_list ',' INLINE type_name enumerator_value_opt 2298 { $$ = $1->appendList( DeclarationNode::newEnumConstant( new string("inline"), nullptr ) ); } 2232 2299 ; 2233 2300 … … 2237 2304 // | '=' constant_expression 2238 2305 // { $$ = $2; } 2239 | '='initializer2306 | simple_assignment_operator initializer 2240 2307 { $$ = $2->get_expression(); } // FIX ME: enum only deals with constant_expression 2241 2308 ; … … 2365 2432 // empty 2366 2433 { $$ = nullptr; } 2367 | '=' initializer 2368 { $$ = $2; } 2369 | '=' VOID 2370 { $$ = new InitializerNode( true ); } 2371 | ATassign initializer 2372 { $$ = $2->set_maybeConstructed( false ); } 2434 | simple_assignment_operator initializer { $$ = $1 == OperKinds::Assign ? $2 : $2->set_maybeConstructed( false ); } 2435 | '=' VOID { $$ = new InitializerNode( true ); } 2373 2436 ; 2374 2437 … … 2626 2689 2627 2690 external_definition: 2628 declaration 2691 DIRECTIVE 2692 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); } 2693 | declaration 2629 2694 | external_function_definition 2630 2695 | EXTENSION external_definition // GCC, multiple __extension__ allowed, meaning unknown … … 2634 2699 } 2635 2700 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 2636 { 2637 $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); 2638 } 2701 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); } 2639 2702 | EXTERN STRINGliteral // C++-style linkage specifier 2640 2703 { … … 2782 2845 ; 2783 2846 2784 attribute_opt:2785 // empty2786 { $$ = nullptr; }2787 | attribute2788 ;2789 2790 2847 attribute: // GCC 2791 2848 ATTRIBUTE '(' '(' attribute_name_list ')' ')' … … 2849 2906 // declaring an array of functions versus a pointer to an array of functions. 2850 2907 2908 paren_identifier: 2909 identifier 2910 { $$ = DeclarationNode::newName( $1 ); } 2911 | '(' paren_identifier ')' // redundant parenthesis 2912 { $$ = $2; } 2913 ; 2914 2851 2915 variable_declarator: 2852 2916 paren_identifier attribute_list_opt … … 2859 2923 ; 2860 2924 2861 paren_identifier:2862 identifier2863 { $$ = DeclarationNode::newName( $1 ); }2864 | '(' paren_identifier ')' // redundant parenthesis2865 { $$ = $2; }2866 ;2867 2868 2925 variable_ptr: 2869 2926 ptrref_operator variable_declarator … … 2871 2928 | ptrref_operator type_qualifier_list variable_declarator 2872 2929 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2873 | '(' variable_ptr ')' attribute_list_opt 2874 { $$ = $2->addQualifiers( $4 ); } // redundant parenthesis 2930 | '(' variable_ptr ')' attribute_list_opt // redundant parenthesis 2931 { $$ = $2->addQualifiers( $4 ); } 2932 | '(' attribute_list variable_ptr ')' attribute_list_opt // redundant parenthesis 2933 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); } 2875 2934 ; 2876 2935 … … 2880 2939 | '(' variable_ptr ')' array_dimension 2881 2940 { $$ = $2->addArray( $4 ); } 2882 | '(' variable_array ')' multi_array_dimension // redundant parenthesis 2941 | '(' attribute_list variable_ptr ')' array_dimension 2942 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 2943 | '(' variable_array ')' multi_array_dimension // redundant parenthesis 2883 2944 { $$ = $2->addArray( $4 ); } 2945 | '(' attribute_list variable_array ')' multi_array_dimension // redundant parenthesis 2946 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 2884 2947 | '(' variable_array ')' // redundant parenthesis 2885 2948 { $$ = $2; } 2949 | '(' attribute_list variable_array ')' // redundant parenthesis 2950 { $$ = $3->addQualifiers( $2 ); } 2886 2951 ; 2887 2952 … … 2889 2954 '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2890 2955 { $$ = $2->addParamList( $6 ); } 2956 | '(' attribute_list variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2957 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 2891 2958 | '(' variable_function ')' // redundant parenthesis 2892 2959 { $$ = $2; } 2960 | '(' attribute_list variable_function ')' // redundant parenthesis 2961 { $$ = $3->addQualifiers( $2 ); } 2893 2962 ; 2894 2963 … … 2910 2979 | '(' function_ptr ')' '(' push parameter_type_list_opt pop ')' 2911 2980 { $$ = $2->addParamList( $6 ); } 2981 | '(' attribute_list function_ptr ')' '(' push parameter_type_list_opt pop ')' 2982 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 2912 2983 | '(' function_no_ptr ')' // redundant parenthesis 2913 2984 { $$ = $2; } 2985 | '(' attribute_list function_no_ptr ')' // redundant parenthesis 2986 { $$ = $3->addQualifiers( $2 ); } 2914 2987 ; 2915 2988 … … 2919 2992 | ptrref_operator type_qualifier_list function_declarator 2920 2993 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2921 | '(' function_ptr ')' 2922 { $$ = $2; } 2994 | '(' function_ptr ')' attribute_list_opt 2995 { $$ = $2->addQualifiers( $4 ); } 2996 | '(' attribute_list function_ptr ')' attribute_list_opt 2997 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); } 2923 2998 ; 2924 2999 … … 2926 3001 '(' function_ptr ')' array_dimension 2927 3002 { $$ = $2->addArray( $4 ); } 3003 | '(' attribute_list function_ptr ')' array_dimension 3004 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 2928 3005 | '(' function_array ')' multi_array_dimension // redundant parenthesis 2929 3006 { $$ = $2->addArray( $4 ); } 3007 | '(' attribute_list function_array ')' multi_array_dimension // redundant parenthesis 3008 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 2930 3009 | '(' function_array ')' // redundant parenthesis 2931 3010 { $$ = $2; } 3011 | '(' attribute_list function_array ')' // redundant parenthesis 3012 { $$ = $3->addQualifiers( $2 ); } 2932 3013 ; 2933 3014 … … 2950 3031 | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')' 2951 3032 { $$ = $2->addParamList( $6 ); } 3033 | '(' attribute_list KR_function_ptr ')' '(' push parameter_type_list_opt pop ')' 3034 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 2952 3035 | '(' KR_function_no_ptr ')' // redundant parenthesis 2953 3036 { $$ = $2; } 3037 | '(' attribute_list KR_function_no_ptr ')' // redundant parenthesis 3038 { $$ = $3->addQualifiers( $2 ); } 2954 3039 ; 2955 3040 … … 2961 3046 | '(' KR_function_ptr ')' 2962 3047 { $$ = $2; } 3048 | '(' attribute_list KR_function_ptr ')' 3049 { $$ = $3->addQualifiers( $2 ); } 2963 3050 ; 2964 3051 … … 2966 3053 '(' KR_function_ptr ')' array_dimension 2967 3054 { $$ = $2->addArray( $4 ); } 3055 | '(' attribute_list KR_function_ptr ')' array_dimension 3056 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 2968 3057 | '(' KR_function_array ')' multi_array_dimension // redundant parenthesis 2969 3058 { $$ = $2->addArray( $4 ); } 3059 | '(' attribute_list KR_function_array ')' multi_array_dimension // redundant parenthesis 3060 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 2970 3061 | '(' KR_function_array ')' // redundant parenthesis 2971 3062 { $$ = $2; } 3063 | '(' attribute_list KR_function_array ')' // redundant parenthesis 3064 { $$ = $3->addQualifiers( $2 ); } 2972 3065 ; 2973 3066 … … 2981 3074 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays 2982 3075 // and functions versus pointers to arrays and functions. 3076 3077 paren_type: 3078 typedef_name 3079 { 3080 // hide type name in enclosing scope by variable name 3081 typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" ); 3082 } 3083 | '(' paren_type ')' 3084 { $$ = $2; } 3085 ; 2983 3086 2984 3087 variable_type_redeclarator: … … 2992 3095 ; 2993 3096 2994 paren_type:2995 typedef2996 // hide type name in enclosing scope by variable name2997 {2998 // if ( ! typedefTable.existsCurr( *$1->name ) ) {2999 typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" );3000 // } else {3001 // SemanticError( yylloc, string("'") + *$1->name + "' redeclared as different kind of symbol." ); $$ = nullptr;3002 // } // if3003 }3004 | '(' paren_type ')'3005 { $$ = $2; }3006 ;3007 3008 3097 type_ptr: 3009 3098 ptrref_operator variable_type_redeclarator … … 3011 3100 | ptrref_operator type_qualifier_list variable_type_redeclarator 3012 3101 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3013 | '(' type_ptr ')' attribute_list_opt 3014 { $$ = $2->addQualifiers( $4 ); } // redundant parenthesis 3102 | '(' type_ptr ')' attribute_list_opt // redundant parenthesis 3103 { $$ = $2->addQualifiers( $4 ); } 3104 | '(' attribute_list type_ptr ')' attribute_list_opt // redundant parenthesis 3105 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); } 3015 3106 ; 3016 3107 … … 3020 3111 | '(' type_ptr ')' array_dimension 3021 3112 { $$ = $2->addArray( $4 ); } 3113 | '(' attribute_list type_ptr ')' array_dimension 3114 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3022 3115 | '(' type_array ')' multi_array_dimension // redundant parenthesis 3023 3116 { $$ = $2->addArray( $4 ); } 3117 | '(' attribute_list type_array ')' multi_array_dimension // redundant parenthesis 3118 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 3024 3119 | '(' type_array ')' // redundant parenthesis 3025 3120 { $$ = $2; } 3121 | '(' attribute_list type_array ')' // redundant parenthesis 3122 { $$ = $3->addQualifiers( $2 ); } 3026 3123 ; 3027 3124 … … 3031 3128 | '(' type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3032 3129 { $$ = $2->addParamList( $6 ); } 3130 | '(' attribute_list type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3131 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); } 3033 3132 | '(' type_function ')' // redundant parenthesis 3034 3133 { $$ = $2; } 3134 | '(' attribute_list type_function ')' // redundant parenthesis 3135 { $$ = $3->addQualifiers( $2 ); } 3035 3136 ; 3036 3137 … … 3057 3158 | ptrref_operator type_qualifier_list identifier_parameter_declarator 3058 3159 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3059 | '(' identifier_parameter_ptr ')' attribute_list_opt 3160 | '(' identifier_parameter_ptr ')' attribute_list_opt // redundant parenthesis 3060 3161 { $$ = $2->addQualifiers( $4 ); } 3061 3162 ; … … 3091 3192 3092 3193 type_parameter_redeclarator: 3093 typedef attribute_list_opt3194 typedef_name attribute_list_opt 3094 3195 { $$ = $1->addQualifiers( $2 ); } 3095 | '&' MUTEX typedef attribute_list_opt3196 | '&' MUTEX typedef_name attribute_list_opt 3096 3197 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); } 3097 3198 | type_parameter_ptr … … 3102 3203 ; 3103 3204 3104 typedef :3205 typedef_name: 3105 3206 TYPEDEFname 3106 3207 { $$ = DeclarationNode::newName( $1 ); } … … 3114 3215 | ptrref_operator type_qualifier_list type_parameter_redeclarator 3115 3216 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3116 | '(' type_parameter_ptr ')' attribute_list_opt 3217 | '(' type_parameter_ptr ')' attribute_list_opt // redundant parenthesis 3117 3218 { $$ = $2->addQualifiers( $4 ); } 3118 3219 ; 3119 3220 3120 3221 type_parameter_array: 3121 typedef array_parameter_dimension3222 typedef_name array_parameter_dimension 3122 3223 { $$ = $1->addArray( $2 ); } 3123 3224 | '(' type_parameter_ptr ')' array_parameter_dimension … … 3126 3227 3127 3228 type_parameter_function: 3128 typedef '(' push parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)3229 typedef_name '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3129 3230 { $$ = $1->addParamList( $4 ); } 3130 3231 | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) … … 3255 3356 | ptrref_operator type_qualifier_list abstract_parameter_declarator 3256 3357 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3257 | '(' abstract_parameter_ptr ')' attribute_list_opt 3358 | '(' abstract_parameter_ptr ')' attribute_list_opt // redundant parenthesis 3258 3359 { $$ = $2->addQualifiers( $4 ); } 3259 3360 ; … … 3334 3435 | ptrref_operator type_qualifier_list variable_abstract_declarator 3335 3436 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3336 | '(' variable_abstract_ptr ')' attribute_list_opt 3437 | '(' variable_abstract_ptr ')' attribute_list_opt // redundant parenthesis 3337 3438 { $$ = $2->addQualifiers( $4 ); } 3338 3439 ;
Note:
See TracChangeset
for help on using the changeset viewer.