Changes in src/Parser/parser.yy [efc8f3e:6cebfef]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
refc8f3e r6cebfef 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Oct 15 09:20:17202113 // Update Count : 5 16312 // Last Modified On : Tue Jul 20 22:03:04 2021 13 // Update Count : 5031 14 14 // 15 15 … … 31 31 // from ANSI90 to ANSI11 C are marked with the comment "C99/C11". 32 32 33 // This grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions .All of the33 // This grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions All of the 34 34 // syntactic extensions for GCC C are marked with the comment "GCC". The second extensions are for Cforall (CFA), which 35 35 // fixes several of C's outstanding problems and extends C with many modern language concepts. All of the syntactic … … 69 69 // 2. String encodings are transformed into canonical form (one encoding at start) so the encoding can be found 70 70 // without searching the string, e.g.: "abc" L"def" L"ghi" => L"abc" "def" "ghi". Multiple encodings must match, 71 // e.g., u"a" U"b" L"c" is disallowed.71 // i.e., u"a" U"b" L"c" is disallowed. 72 72 73 73 if ( from[0] != '"' ) { // encoding ? … … 185 185 type = new ExpressionNode( new CastExpr( maybeMoveBuild<Expression>(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) ); 186 186 } // if 187 // type = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__for_control_index_constraints__" ) ) ), type ) );188 187 return new ForCtrl( 189 188 distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), … … 310 309 %token ATassign // @= 311 310 312 %type<tok> identifier identifier_at identifier_or_type_name attr_name 311 %type<tok> identifier 312 %type<tok> identifier_or_type_name attr_name 313 313 %type<tok> quasi_keyword 314 314 %type<constant> string_literal … … 326 326 %type<en> conditional_expression constant_expression assignment_expression assignment_expression_opt 327 327 %type<en> comma_expression comma_expression_opt 328 %type<en> argument_expression_list_opt argument_expression _list argument_expressiondefault_initializer_opt328 %type<en> argument_expression_list_opt argument_expression default_initializer_opt 329 329 %type<ifctl> if_control_expression 330 330 %type<fctl> for_control_expression for_control_expression_list … … 558 558 IDENTIFIER 559 559 | quasi_keyword 560 ;561 562 identifier_at:563 identifier564 560 | '@' // CFA 565 561 { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; } … … 696 692 // empty 697 693 { $$ = nullptr; } 698 | argument_expression_list 699 ; 700 701 argument_expression_list: 702 argument_expression 694 | argument_expression 703 695 | argument_expression_list_opt ',' argument_expression 704 696 { $$ = (ExpressionNode *)($1->set_last( $3 )); } … … 738 730 | FLOATINGconstant fraction_constants_opt 739 731 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 740 | identifier _at fraction_constants_opt // CFA, allow anonymous fields732 | identifier fraction_constants_opt 741 733 { 742 734 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 1091 1083 comma_expression_opt ';' 1092 1084 { $$ = new StatementNode( build_expr( $1 ) ); } 1093 | MUTEX '(' ')' comma_expression ';'1094 { $$ = new StatementNode( build_mutex( nullptr, new StatementNode( build_expr( $4 ) ) ) ); }1095 // { SemanticError( yylloc, "Mutex expression is currently unimplemented." ); $$ = nullptr; }1096 1085 ; 1097 1086 … … 1192 1181 1193 1182 iteration_statement: 1194 WHILE '(' ')' statement // CFA => while ( 1 ) 1183 WHILE '(' push if_control_expression ')' statement pop 1184 { $$ = new StatementNode( build_while( $4, maybe_build_compound( $6 ) ) ); } 1185 | WHILE '(' ')' statement // CFA => while ( 1 ) 1195 1186 { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); } 1196 | WHILE '(' if_control_expression ')' statement %prec THEN 1197 { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); } 1198 | WHILE '(' if_control_expression ')' statement ELSE statement // CFA 1199 { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; } 1187 | DO statement WHILE '(' comma_expression ')' ';' 1188 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); } 1200 1189 | DO statement WHILE '(' ')' ';' // CFA => do while( 1 ) 1201 1190 { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); } 1202 | DO statement WHILE '(' comma_expression ')' ';' %prec THEN 1203 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); } 1204 | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA 1205 { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; } 1191 | FOR '(' push for_control_expression_list ')' statement pop 1192 { $$ = new StatementNode( build_for( $4, maybe_build_compound( $6 ) ) ); } 1206 1193 | FOR '(' ')' statement // CFA => for ( ;; ) 1207 1194 { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); } 1208 | FOR '(' for_control_expression_list ')' statement %prec THEN1209 { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }1210 | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA1211 { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }1212 1195 ; 1213 1196 … … 1355 1338 with_statement: 1356 1339 WITH '(' tuple_expression_list ')' statement 1357 { $$ = new StatementNode( build_with( $3, $5 ) ); } 1340 { 1341 $$ = new StatementNode( build_with( $3, $5 ) ); 1342 } 1358 1343 ; 1359 1344 1360 1345 // If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex". 1361 1346 mutex_statement: 1362 MUTEX '(' argument_expression_list ')' statement1347 MUTEX '(' argument_expression_list_opt ')' statement 1363 1348 { $$ = new StatementNode( build_mutex( $3, $5 ) ); } 1364 1349 ; … … 2460 2445 | simple_assignment_operator initializer { $$ = $1 == OperKinds::Assign ? $2 : $2->set_maybeConstructed( false ); } 2461 2446 | '=' VOID { $$ = new InitializerNode( true ); } 2462 | '{' initializer_list_opt comma_opt '}' { $$ = new InitializerNode( $2, true ); }2463 2447 ; 2464 2448 … … 2474 2458 | designation initializer { $$ = $2->set_designators( $1 ); } 2475 2459 | initializer_list_opt ',' initializer { $$ = (InitializerNode *)( $1->set_last( $3 ) ); } 2476 | initializer_list_opt ',' designation initializer { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); } 2460 | initializer_list_opt ',' designation initializer 2461 { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); } 2477 2462 ; 2478 2463 … … 2489 2474 designation: 2490 2475 designator_list ':' // C99, CFA uses ":" instead of "=" 2491 | identifier _at':' // GCC, field name2476 | identifier ':' // GCC, field name 2492 2477 { $$ = new ExpressionNode( build_varref( $1 ) ); } 2493 2478 ; … … 2501 2486 2502 2487 designator: 2503 '.' identifier _at// C99, field name2488 '.' identifier // C99, field name 2504 2489 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2505 2490 | '[' push assignment_expression pop ']' // C99, single array element … … 2933 2918 2934 2919 paren_identifier: 2935 identifier _at2920 identifier 2936 2921 { $$ = DeclarationNode::newName( $1 ); } 2937 2922 | '(' paren_identifier ')' // redundant parenthesis
Note:
See TracChangeset
for help on using the changeset viewer.