Changeset 7e13b11 for src/Parser/parser.yy
- Timestamp:
- Mar 6, 2024, 10:59:19 AM (2 months ago)
- Branches:
- master
- Children:
- 56b47b9
- Parents:
- 7a29392f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r7a29392f r7e13b11 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 4 08:44:25 202413 // Update Count : 65 6212 // Last Modified On : Wed Mar 6 10:51:55 2024 13 // Update Count : 6588 14 14 // 15 15 … … 938 938 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 939 939 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); } 940 941 // Cannot use rule "type", which includes cfa_abstract_function, for sizeof/alignof, because of S/R problems on 942 // look ahead, so the cfa_abstract_function is factored out. 943 | SIZEOF '(' cfa_abstract_function ')' 944 { $$ = new ExpressionNode( new ast::SizeofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); } 945 | ALIGNOF '(' cfa_abstract_function ')' // GCC, type alignment 946 { $$ = new ExpressionNode( new ast::AlignofExpr( yylloc, maybeMoveBuildType( $3 ) ) ); } 947 940 948 | OFFSETOF '(' type_no_function ',' identifier ')' 941 949 { $$ = new ExpressionNode( build_offsetOf( yylloc, $3, build_varref( yylloc, $5 ) ) ); } 942 | TYPEID '(' type _no_function')'950 | TYPEID '(' type ')' 943 951 { 944 952 SemanticError( yylloc, "typeid name is currently unimplemented." ); $$ = nullptr; … … 1238 1246 { assert( $1 ); $1->set_last( $2 ); $$ = $1; } 1239 1247 | statement_list_nodecl error // invalid syntax rule 1240 { SemanticError( yylloc, "syntax error, declarations only allowed at the start of the switch body, i.e., after the '{'." ); $$ = nullptr; } 1248 { SemanticError( yylloc, "syntax error, declarations only allowed at the start of the switch body," 1249 " i.e., after the '{'." ); $$ = nullptr; } 1241 1250 ; 1242 1251 … … 1246 1255 ; 1247 1256 1248 // if, switch, and choose require parenthesis around the conditional because it can be followed by a statement. 1249 // For example, without parenthesis: 1250 // 1251 // if x + y + z; => "if ( x + y ) + z" or "if ( x ) + y + z" 1252 // switch ( S ) { ... } => switch ( S ) { compound literal... } ... or 1257 // "if", "switch", and "choose" require parenthesis around the conditional. See the following ambiguities without 1258 // parenthesis: 1259 // 1260 // if x + y + z; => "if ( x + y ) + z" or "if ( x ) + y + z" 1261 // 1262 // switch O { } 1263 // 1264 // O{} => object-constructor for conditional, switch body ??? 1265 // O{} => O for conditional followed by switch body 1266 // 1267 // C++ has this problem, as it has the same constructor syntax. 1268 // 1269 // switch sizeof ( T ) { } 1270 // 1271 // sizeof ( T ) => sizeof of T for conditional followed by switch body 1272 // sizeof ( T ) => sizeof of compound literal (T){ }, closing parenthesis ??? 1273 // 1274 // Note the two grammar rules for sizeof (alignof) 1275 // 1276 // | SIZEOF unary_expression 1277 // | SIZEOF '(' type_no_function ')' 1278 // 1279 // where the first DOES NOT require parenthesis! And C++ inherits this problem from C. 1253 1280 1254 1281 selection_statement: … … 2200 2227 | ATOMIC 2201 2228 { $$ = DeclarationNode::newTypeQualifier( ast::CV::Atomic ); } 2229 2230 // forall must be a CV qualifier because it can appear in places where SC qualifiers are disallowed. 2231 // 2232 // void foo( forall( T ) T (*)( T ) ); // forward declaration 2233 // void bar( static int ); // static disallowed (gcc/CFA) 2202 2234 | forall 2203 2235 { $$ = DeclarationNode::newForall( $1 ); } … … 2464 2496 ; 2465 2497 2498 // ************************** AGGREGATE ******************************* 2499 2466 2500 aggregate_type: // struct, union 2467 2501 aggregate_key attribute_list_opt … … 2544 2578 | EXCEPTION // CFA 2545 2579 { $$ = ast::AggregateDecl::Exception; } 2546 // { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = ast::AggregateDecl::NoAggregate; }2547 2580 ; 2548 2581 … … 2683 2716 ; 2684 2717 2685 // *********** 2686 // Enumeration 2687 // *********** 2718 // ************************** ENUMERATION ******************************* 2688 2719 2689 2720 enum_type: … … 2785 2816 ; 2786 2817 2787 // ******************* 2788 // Function parameters 2789 // ******************* 2818 // ************************** FUNCTION PARAMETERS ******************************* 2790 2819 2791 2820 parameter_list_ellipsis_opt: … … 2868 2897 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initializer_opt 2869 2898 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 2870 | cfa_function_specifier 2899 | cfa_function_specifier // int f( "int fp()" ); 2871 2900 ; 2872 2901 … … 2878 2907 | type_qualifier_list cfa_abstract_tuple 2879 2908 { $$ = $2->addQualifiers( $1 ); } 2880 | cfa_abstract_function 2909 | cfa_abstract_function // int f( "int ()" ); 2881 2910 ; 2882 2911 … … 3036 3065 { $$ = ast::TypeDecl::Dtype; } 3037 3066 | '*' 3038 { $$ = ast::TypeDecl::DStype; } // dtype + sized3039 // | '(' '*' ')' 3040 // { $$ = ast::TypeDecl::Ftype; }3067 { $$ = ast::TypeDecl::DStype; } // Dtype + sized 3068 // | '(' '*' ')' // Gregor made me do it 3069 // { $$ = ast::TypeDecl::Ftype; } 3041 3070 | ELLIPSIS 3042 3071 { $$ = ast::TypeDecl::Ttype; } … … 3244 3273 $$ = $6; 3245 3274 } 3246 // global distribution3275 // global distribution 3247 3276 | type_qualifier_list 3248 3277 { … … 3369 3398 ; 3370 3399 3400 // **************************** ASM ***************************** 3401 3371 3402 asm_name_opt: // GCC 3372 3403 // empty … … 3379 3410 } 3380 3411 ; 3412 3413 // **************************** ATTRIBUTE ***************************** 3381 3414 3382 3415 attribute_list_opt: // GCC … … 3826 3859 3827 3860 type_parameter_function: 3828 typedef_name '(' parameter_list_ellipsis_opt ')' 3861 typedef_name '(' parameter_list_ellipsis_opt ')' // empty parameter list OBSOLESCENT (see 3) 3829 3862 { $$ = $1->addParamList( $3 ); } 3830 3863 | '(' type_parameter_ptr ')' '(' parameter_list_ellipsis_opt ')' // empty parameter list OBSOLESCENT (see 3) … … 3876 3909 3877 3910 abstract_function: 3878 '(' parameter_list_ellipsis_opt ')' // empty parameter list OBSOLESCENT (see 3)3911 '(' parameter_list_ellipsis_opt ')' // empty parameter list OBSOLESCENT (see 3) 3879 3912 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); } 3880 3913 | '(' abstract_ptr ')' '(' parameter_list_ellipsis_opt ')' // empty parameter list OBSOLESCENT (see 3) … … 4008 4041 4009 4042 abstract_parameter_function: 4010 '(' parameter_list_ellipsis_opt ')' // empty parameter list OBSOLESCENT (see 3)4043 '(' parameter_list_ellipsis_opt ')' // empty parameter list OBSOLESCENT (see 3) 4011 4044 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); } 4012 4045 | '(' abstract_parameter_ptr ')' '(' parameter_list_ellipsis_opt ')' // empty parameter list OBSOLESCENT (see 3) … … 4280 4313 // mode: c++ // 4281 4314 // tab-width: 4 // 4282 // compile-command: " make install" //4315 // compile-command: "bison -Wcounterexamples parser.yy" // 4283 4316 // End: //
Note: See TracChangeset
for help on using the changeset viewer.