Changes in src/Parser/parser.yy [24711a3:6a99803]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (53 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r24711a3 r6a99803 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Apr 26 18:41:54202113 // Update Count : 4 99012 // Last Modified On : Wed Feb 3 18:30:12 2021 13 // Update Count : 4700 14 14 // 15 15 … … 32 32 // 33 33 // 1. designation with and without '=' (use ':' instead) 34 34 // 2. attributes not allowed in parenthesis of declarator 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 ;// aggregate have one or more forall qualifiers ?213 bool forall = false, yyy = 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 VTABLE COERCE// CFA266 %token FORALL MUTEX VIRTUAL 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 SIZEOF TYPEOF VALIST AUTO_TYPE // GCC 273 %token OFFSETOF BASETYPEOF TYPEID // CFA 272 %token VALIST // GCC 273 %token AUTO_TYPE // GCC 274 %token TYPEOF BASETYPEOF LABEL // GCC 274 275 %token ENUM STRUCT UNION 275 276 %token EXCEPTION // CFA 276 277 %token GENERATOR COROUTINE MONITOR THREAD // CFA 277 278 %token OTYPE FTYPE DTYPE TTYPE TRAIT // CFA 279 %token SIZEOF OFFSETOF 278 280 // %token RESUME // CFA 279 %token LABEL // GCC280 281 %token SUSPEND // CFA 281 282 %token ATTRIBUTE EXTENSION // GCC 282 283 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 283 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR // CFA 284 %token DISABLE ENABLE TRY THROW THROWRESUME AT // CFA 284 %token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGH TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // 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 WOR CATCH RECOVER CATCHRESUME FIXUP FINALLY // CFA291 %token<tok> INTEGERconstant CHARACTERconstantSTRINGliteral289 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFname TYPEGENname 290 %token<tok> TIMEOUT WOR 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 simple_assignment_operator compound_assignment_operator323 %type<op> ptrref_operator unary_operator 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_opt376 375 377 376 %type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier … … 429 428 430 429 %type<decl> type_declaration_specifier type_type_specifier type_name typegen_name 431 %type<decl> typedef _nametypedef_declaration typedef_expression430 %type<decl> typedef typedef_declaration typedef_expression 432 431 433 432 %type<decl> variable_type_redeclarator type_ptr type_array type_function … … 441 440 442 441 %type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list 443 %type<decl> type_specifier type_specifier_nobody 442 %type<decl> type_specifier type_specifier_nobody enum_specifier_nobody 444 443 445 444 %type<decl> variable_declarator variable_ptr variable_array variable_function 446 445 %type<decl> variable_abstract_declarator variable_abstract_ptr variable_abstract_array variable_abstract_function 447 446 448 %type<decl> attribute_list_opt attribute_list attribute attribute_name_list attribute_name447 %type<decl> attribute_list_opt attribute_list attribute_opt attribute attribute_name_list attribute_name 449 448 450 449 // initializers … … 463 462 // Order of these lines matters (low-to-high precedence). THEN is left associative over WOR/TIMEOUT/ELSE, WOR is left 464 463 // associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE. 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 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 475 468 476 469 // Handle shift/reduce conflict for generic type by shifting the '(' token. For example, this string is ambiguous: … … 551 544 TIMEOUT 552 545 | WOR 553 | CATCH554 | RECOVER555 | CATCHRESUME556 | FIXUP557 | FINALLY558 546 ; 559 547 … … 786 774 | OFFSETOF '(' type_no_function ',' identifier ')' 787 775 { $$ = 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 }793 776 ; 794 777 … … 812 795 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 813 796 | '(' aggregate_control '&' ')' cast_expression // CFA 814 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }815 | '(' aggregate_control '*' ')' cast_expression // CFA816 797 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 817 798 | '(' VIRTUAL ')' cast_expression // CFA … … 958 939 959 940 assignment_operator: 960 simple_assignment_operator961 | compound_assignment_operator962 ;963 964 simple_assignment_operator:965 941 '=' { $$ = OperKinds::Assign; } 966 | ATassign { $$ = OperKinds::AtAssn; } // CFA 967 ; 968 969 compound_assignment_operator: 970 EXPassign { $$ = OperKinds::ExpAssn; } 942 | ATassign { $$ = OperKinds::AtAssn; } 943 | EXPassign { $$ = OperKinds::ExpAssn; } 971 944 | MULTassign { $$ = OperKinds::MulAssn; } 972 945 | DIVassign { $$ = OperKinds::DivAssn; } … … 1046 1019 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); } 1047 1020 | '{' push 1048 local_label_declaration_opt // GCC, local labels appear at start of block1021 local_label_declaration_opt // GCC, local labels 1049 1022 statement_decl_list // C99, intermix declarations and statements 1050 1023 pop '}' … … 1244 1217 | comma_expression ';' comma_expression inclexcl comma_expression '~' comma_expression // CFA 1245 1218 { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, $7 ); } 1246 1247 | comma_expression ';' TYPEDEFname // CFA, array type1248 {1249 SemanticError( yylloc, "Array interator is currently unimplemented." ); $$ = nullptr;1250 $$ = forCtrl( new ExpressionNode( build_varref( $3 ) ), $1, nullptr, OperKinds::Range, nullptr, nullptr );1251 }1252 1219 1253 1220 // There is a S/R conflicit if ~ and -~ are factored out. … … 1399 1366 1400 1367 exception_statement: 1401 TRY compound_statement handler_clause %prec THEN1368 TRY compound_statement handler_clause 1402 1369 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 1403 1370 | TRY compound_statement finally_clause … … 1422 1389 handler_key: 1423 1390 CATCH { $$ = CatchStmt::Terminate; } 1424 | RECOVER { $$ = CatchStmt::Terminate; }1425 1391 | CATCHRESUME { $$ = CatchStmt::Resume; } 1426 | FIXUP { $$ = CatchStmt::Resume; }1427 1392 ; 1428 1393 … … 1776 1741 ; 1777 1742 1743 enum_specifier_nobody: // type specifier - {...} 1744 // Preclude SUE declarations in restricted scopes (see type_specifier_nobody) 1745 basic_type_specifier 1746 | sue_type_specifier_nobody 1747 ; 1748 1778 1749 type_qualifier_list_opt: // GCC, used in asm_statement 1779 1750 // empty … … 1795 1766 type_qualifier: 1796 1767 type_qualifier_name 1797 | attribute // trick handles most atrribute locations1768 | attribute 1798 1769 ; 1799 1770 … … 1903 1874 | AUTO_TYPE 1904 1875 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); } 1905 | vtable1906 ;1907 1908 vtable_opt:1909 // empty1910 { $$ = nullptr; }1911 | vtable;1912 ;1913 1914 vtable:1915 VTABLE '(' type_list ')' default_opt1916 { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }1917 ;1918 1919 default_opt:1920 // empty1921 { $$ = nullptr; }1922 | DEFAULT1923 { SemanticError( yylloc, "vtable default is currently unimplemented." ); $$ = nullptr; }1924 1876 ; 1925 1877 … … 2073 2025 '{' field_declaration_list_opt '}' type_parameters_opt 2074 2026 { $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); } 2075 | aggregate_key attribute_list_opt TYPEDEFname // unqualified type name 2076 { 2077 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef 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 2078 2031 forall = false; // reset 2079 2032 } 2080 2033 '{' field_declaration_list_opt '}' type_parameters_opt 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 } 2034 { $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $8, $6, true )->addQualifiers( $2 ); } 2095 2035 | aggregate_type_nobody 2096 2036 ; … … 2129 2069 2130 2070 aggregate_data: 2131 STRUCT vtable_opt2132 { $$ = AggregateDecl::Struct; }2071 STRUCT 2072 { yyy = true; $$ = AggregateDecl::Struct; } 2133 2073 | UNION 2134 { $$ = AggregateDecl::Union; }2074 { yyy = true; $$ = AggregateDecl::Union; } 2135 2075 | EXCEPTION // CFA 2136 {$$ = AggregateDecl::Exception; }2137 //{ SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }2076 // { yyy = true; $$ = AggregateDecl::Exception; } 2077 { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2138 2078 ; 2139 2079 2140 2080 aggregate_control: // CFA 2141 2081 MONITOR 2142 { $$ = AggregateDecl::Monitor; }2082 { yyy = true; $$ = AggregateDecl::Monitor; } 2143 2083 | MUTEX STRUCT 2144 { $$ = AggregateDecl::Monitor; }2084 { yyy = true; $$ = AggregateDecl::Monitor; } 2145 2085 | GENERATOR 2146 { $$ = AggregateDecl::Generator; }2086 { yyy = true; $$ = AggregateDecl::Generator; } 2147 2087 | MUTEX GENERATOR 2148 2088 { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2149 2089 | COROUTINE 2150 { $$ = AggregateDecl::Coroutine; }2090 { yyy = true; $$ = AggregateDecl::Coroutine; } 2151 2091 | MUTEX COROUTINE 2152 2092 { SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } 2153 2093 | THREAD 2154 { $$ = AggregateDecl::Thread; }2094 { yyy = true; $$ = AggregateDecl::Thread; } 2155 2095 | MUTEX THREAD 2156 2096 { SemanticError( yylloc, "monitor thread is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; } … … 2248 2188 ; 2249 2189 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". 2250 2192 enum_type: // enum 2251 ENUM attribute_ list_opt '{' enumerator_list comma_opt '}'2193 ENUM attribute_opt '{' enumerator_list comma_opt '}' 2252 2194 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 2253 | ENUM attribute_ list_opt identifier2195 | ENUM attribute_opt identifier 2254 2196 { typedefTable.makeTypedef( *$3 ); } 2255 2197 '{' enumerator_list comma_opt '}' 2256 2198 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); } 2257 | ENUM attribute_ list_opt typedef_name // unqualified type name2199 | ENUM attribute_opt typedef // enum cannot be generic 2258 2200 '{' enumerator_list comma_opt '}' 2259 2201 { $$ = DeclarationNode::newEnum( $3->name, $5, true )->addQualifiers( $2 ); } 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 } 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; } 2280 2211 | enum_type_nobody 2281 2212 ; 2282 2213 2283 2214 enum_type_nobody: // enum - {...} 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 ); } 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 } 2288 2225 ; 2289 2226 … … 2291 2228 identifier_or_type_name enumerator_value_opt 2292 2229 { $$ = DeclarationNode::newEnumConstant( $1, $2 ); } 2293 | INLINE type_name2294 { $$ = DeclarationNode::newEnumConstant( new string("inline"), nullptr ); }2295 2230 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2296 2231 { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); } 2297 | enumerator_list ',' INLINE type_name enumerator_value_opt2298 { $$ = $1->appendList( DeclarationNode::newEnumConstant( new string("inline"), nullptr ) ); }2299 2232 ; 2300 2233 … … 2304 2237 // | '=' constant_expression 2305 2238 // { $$ = $2; } 2306 | simple_assignment_operatorinitializer2239 | '=' initializer 2307 2240 { $$ = $2->get_expression(); } // FIX ME: enum only deals with constant_expression 2308 2241 ; … … 2432 2365 // empty 2433 2366 { $$ = nullptr; } 2434 | simple_assignment_operator initializer { $$ = $1 == OperKinds::Assign ? $2 : $2->set_maybeConstructed( false ); } 2435 | '=' VOID { $$ = new InitializerNode( true ); } 2367 | '=' initializer 2368 { $$ = $2; } 2369 | '=' VOID 2370 { $$ = new InitializerNode( true ); } 2371 | ATassign initializer 2372 { $$ = $2->set_maybeConstructed( false ); } 2436 2373 ; 2437 2374 … … 2689 2626 2690 2627 external_definition: 2691 DIRECTIVE 2692 { $$ = DeclarationNode::newDirectiveStmt( new StatementNode( build_directive( $1 ) ) ); } 2693 | declaration 2628 declaration 2694 2629 | external_function_definition 2695 2630 | EXTENSION external_definition // GCC, multiple __extension__ allowed, meaning unknown … … 2699 2634 } 2700 2635 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 2701 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); } 2636 { 2637 $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); 2638 } 2702 2639 | EXTERN STRINGliteral // C++-style linkage specifier 2703 2640 { … … 2845 2782 ; 2846 2783 2784 attribute_opt: 2785 // empty 2786 { $$ = nullptr; } 2787 | attribute 2788 ; 2789 2847 2790 attribute: // GCC 2848 2791 ATTRIBUTE '(' '(' attribute_name_list ')' ')' … … 2906 2849 // declaring an array of functions versus a pointer to an array of functions. 2907 2850 2908 paren_identifier:2909 identifier2910 { $$ = DeclarationNode::newName( $1 ); }2911 | '(' paren_identifier ')' // redundant parenthesis2912 { $$ = $2; }2913 ;2914 2915 2851 variable_declarator: 2916 2852 paren_identifier attribute_list_opt … … 2923 2859 ; 2924 2860 2861 paren_identifier: 2862 identifier 2863 { $$ = DeclarationNode::newName( $1 ); } 2864 | '(' paren_identifier ')' // redundant parenthesis 2865 { $$ = $2; } 2866 ; 2867 2925 2868 variable_ptr: 2926 2869 ptrref_operator variable_declarator … … 2928 2871 | ptrref_operator type_qualifier_list variable_declarator 2929 2872 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 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 ); } 2873 | '(' variable_ptr ')' attribute_list_opt 2874 { $$ = $2->addQualifiers( $4 ); } // redundant parenthesis 2934 2875 ; 2935 2876 … … 2939 2880 | '(' variable_ptr ')' array_dimension 2940 2881 { $$ = $2->addArray( $4 ); } 2941 | '(' attribute_list variable_ptr ')' array_dimension 2942 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); } 2943 | '(' variable_array ')' multi_array_dimension // redundant parenthesis 2882 | '(' variable_array ')' multi_array_dimension // redundant parenthesis 2944 2883 { $$ = $2->addArray( $4 ); } 2945 | '(' attribute_list variable_array ')' multi_array_dimension // redundant parenthesis2946 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }2947 2884 | '(' variable_array ')' // redundant parenthesis 2948 2885 { $$ = $2; } 2949 | '(' attribute_list variable_array ')' // redundant parenthesis2950 { $$ = $3->addQualifiers( $2 ); }2951 2886 ; 2952 2887 … … 2954 2889 '(' variable_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2955 2890 { $$ = $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 ); }2958 2891 | '(' variable_function ')' // redundant parenthesis 2959 2892 { $$ = $2; } 2960 | '(' attribute_list variable_function ')' // redundant parenthesis2961 { $$ = $3->addQualifiers( $2 ); }2962 2893 ; 2963 2894 … … 2979 2910 | '(' function_ptr ')' '(' push parameter_type_list_opt pop ')' 2980 2911 { $$ = $2->addParamList( $6 ); } 2981 | '(' attribute_list function_ptr ')' '(' push parameter_type_list_opt pop ')'2982 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }2983 2912 | '(' function_no_ptr ')' // redundant parenthesis 2984 2913 { $$ = $2; } 2985 | '(' attribute_list function_no_ptr ')' // redundant parenthesis2986 { $$ = $3->addQualifiers( $2 ); }2987 2914 ; 2988 2915 … … 2992 2919 | ptrref_operator type_qualifier_list function_declarator 2993 2920 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 2994 | '(' function_ptr ')' attribute_list_opt 2995 { $$ = $2->addQualifiers( $4 ); } 2996 | '(' attribute_list function_ptr ')' attribute_list_opt 2997 { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); } 2921 | '(' function_ptr ')' 2922 { $$ = $2; } 2998 2923 ; 2999 2924 … … 3001 2926 '(' function_ptr ')' array_dimension 3002 2927 { $$ = $2->addArray( $4 ); } 3003 | '(' attribute_list function_ptr ')' array_dimension3004 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }3005 2928 | '(' function_array ')' multi_array_dimension // redundant parenthesis 3006 2929 { $$ = $2->addArray( $4 ); } 3007 | '(' attribute_list function_array ')' multi_array_dimension // redundant parenthesis3008 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }3009 2930 | '(' function_array ')' // redundant parenthesis 3010 2931 { $$ = $2; } 3011 | '(' attribute_list function_array ')' // redundant parenthesis3012 { $$ = $3->addQualifiers( $2 ); }3013 2932 ; 3014 2933 … … 3031 2950 | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')' 3032 2951 { $$ = $2->addParamList( $6 ); } 3033 | '(' attribute_list KR_function_ptr ')' '(' push parameter_type_list_opt pop ')'3034 { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }3035 2952 | '(' KR_function_no_ptr ')' // redundant parenthesis 3036 2953 { $$ = $2; } 3037 | '(' attribute_list KR_function_no_ptr ')' // redundant parenthesis3038 { $$ = $3->addQualifiers( $2 ); }3039 2954 ; 3040 2955 … … 3046 2961 | '(' KR_function_ptr ')' 3047 2962 { $$ = $2; } 3048 | '(' attribute_list KR_function_ptr ')'3049 { $$ = $3->addQualifiers( $2 ); }3050 2963 ; 3051 2964 … … 3053 2966 '(' KR_function_ptr ')' array_dimension 3054 2967 { $$ = $2->addArray( $4 ); } 3055 | '(' attribute_list KR_function_ptr ')' array_dimension3056 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }3057 2968 | '(' KR_function_array ')' multi_array_dimension // redundant parenthesis 3058 2969 { $$ = $2->addArray( $4 ); } 3059 | '(' attribute_list KR_function_array ')' multi_array_dimension // redundant parenthesis3060 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }3061 2970 | '(' KR_function_array ')' // redundant parenthesis 3062 2971 { $$ = $2; } 3063 | '(' attribute_list KR_function_array ')' // redundant parenthesis3064 { $$ = $3->addQualifiers( $2 ); }3065 2972 ; 3066 2973 … … 3074 2981 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays 3075 2982 // and functions versus pointers to arrays and functions. 3076 3077 paren_type:3078 typedef_name3079 {3080 // hide type name in enclosing scope by variable name3081 typedefTable.addToEnclosingScope( *$1->name, IDENTIFIER, "ID" );3082 }3083 | '(' paren_type ')'3084 { $$ = $2; }3085 ;3086 2983 3087 2984 variable_type_redeclarator: … … 3095 2992 ; 3096 2993 2994 paren_type: 2995 typedef 2996 // hide type name in enclosing scope by variable name 2997 { 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 // } // if 3003 } 3004 | '(' paren_type ')' 3005 { $$ = $2; } 3006 ; 3007 3097 3008 type_ptr: 3098 3009 ptrref_operator variable_type_redeclarator … … 3100 3011 | ptrref_operator type_qualifier_list variable_type_redeclarator 3101 3012 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 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 ); } 3013 | '(' type_ptr ')' attribute_list_opt 3014 { $$ = $2->addQualifiers( $4 ); } // redundant parenthesis 3106 3015 ; 3107 3016 … … 3111 3020 | '(' type_ptr ')' array_dimension 3112 3021 { $$ = $2->addArray( $4 ); } 3113 | '(' attribute_list type_ptr ')' array_dimension3114 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }3115 3022 | '(' type_array ')' multi_array_dimension // redundant parenthesis 3116 3023 { $$ = $2->addArray( $4 ); } 3117 | '(' attribute_list type_array ')' multi_array_dimension // redundant parenthesis3118 { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }3119 3024 | '(' type_array ')' // redundant parenthesis 3120 3025 { $$ = $2; } 3121 | '(' attribute_list type_array ')' // redundant parenthesis3122 { $$ = $3->addQualifiers( $2 ); }3123 3026 ; 3124 3027 … … 3128 3031 | '(' type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3129 3032 { $$ = $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 ); }3132 3033 | '(' type_function ')' // redundant parenthesis 3133 3034 { $$ = $2; } 3134 | '(' attribute_list type_function ')' // redundant parenthesis3135 { $$ = $3->addQualifiers( $2 ); }3136 3035 ; 3137 3036 … … 3158 3057 | ptrref_operator type_qualifier_list identifier_parameter_declarator 3159 3058 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3160 | '(' identifier_parameter_ptr ')' attribute_list_opt // redundant parenthesis3059 | '(' identifier_parameter_ptr ')' attribute_list_opt 3161 3060 { $$ = $2->addQualifiers( $4 ); } 3162 3061 ; … … 3192 3091 3193 3092 type_parameter_redeclarator: 3194 typedef _nameattribute_list_opt3093 typedef attribute_list_opt 3195 3094 { $$ = $1->addQualifiers( $2 ); } 3196 | '&' MUTEX typedef _nameattribute_list_opt3095 | '&' MUTEX typedef attribute_list_opt 3197 3096 { $$ = $3->addPointer( DeclarationNode::newPointer( DeclarationNode::newTypeQualifier( Type::Mutex ), OperKinds::AddressOf ) )->addQualifiers( $4 ); } 3198 3097 | type_parameter_ptr … … 3203 3102 ; 3204 3103 3205 typedef _name:3104 typedef: 3206 3105 TYPEDEFname 3207 3106 { $$ = DeclarationNode::newName( $1 ); } … … 3215 3114 | ptrref_operator type_qualifier_list type_parameter_redeclarator 3216 3115 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3217 | '(' type_parameter_ptr ')' attribute_list_opt // redundant parenthesis3116 | '(' type_parameter_ptr ')' attribute_list_opt 3218 3117 { $$ = $2->addQualifiers( $4 ); } 3219 3118 ; 3220 3119 3221 3120 type_parameter_array: 3222 typedef _namearray_parameter_dimension3121 typedef array_parameter_dimension 3223 3122 { $$ = $1->addArray( $2 ); } 3224 3123 | '(' type_parameter_ptr ')' array_parameter_dimension … … 3227 3126 3228 3127 type_parameter_function: 3229 typedef _name '(' push parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)3128 typedef '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3230 3129 { $$ = $1->addParamList( $4 ); } 3231 3130 | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) … … 3356 3255 | ptrref_operator type_qualifier_list abstract_parameter_declarator 3357 3256 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3358 | '(' abstract_parameter_ptr ')' attribute_list_opt // redundant parenthesis3257 | '(' abstract_parameter_ptr ')' attribute_list_opt 3359 3258 { $$ = $2->addQualifiers( $4 ); } 3360 3259 ; … … 3435 3334 | ptrref_operator type_qualifier_list variable_abstract_declarator 3436 3335 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } 3437 | '(' variable_abstract_ptr ')' attribute_list_opt // redundant parenthesis3336 | '(' variable_abstract_ptr ')' attribute_list_opt 3438 3337 { $$ = $2->addQualifiers( $4 ); } 3439 3338 ;
Note:
See TracChangeset
for help on using the changeset viewer.