Changeset 1ed9cb63 for src/Parser/parser.yy
- Timestamp:
- Oct 27, 2021, 5:15:41 PM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 40a64f78
- Parents:
- 8a039be (diff), c600df1 (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
r8a039be r1ed9cb63 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 11 08:20:44202113 // Update Count : 5 04012 // Last Modified On : Fri Oct 15 09:20:17 2021 13 // Update Count : 5163 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 // i.e., u"a" U"b" L"c" is disallowed.71 // e.g., u"a" U"b" L"c" is disallowed. 72 72 73 73 if ( from[0] != '"' ) { // encoding ? … … 310 310 %token ATassign // @= 311 311 312 %type<tok> identifier 313 %type<tok> identifier_or_type_name attr_name 312 %type<tok> identifier identifier_at identifier_or_type_name attr_name 314 313 %type<tok> quasi_keyword 315 314 %type<constant> string_literal … … 327 326 %type<en> conditional_expression constant_expression assignment_expression assignment_expression_opt 328 327 %type<en> comma_expression comma_expression_opt 329 %type<en> argument_expression_list_opt argument_expression default_initializer_opt328 %type<en> argument_expression_list_opt argument_expression_list argument_expression default_initializer_opt 330 329 %type<ifctl> if_control_expression 331 330 %type<fctl> for_control_expression for_control_expression_list … … 559 558 IDENTIFIER 560 559 | quasi_keyword 560 ; 561 562 identifier_at: 563 identifier 561 564 | '@' // CFA 562 565 { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; } … … 693 696 // empty 694 697 { $$ = nullptr; } 695 | argument_expression 698 | argument_expression_list 699 ; 700 701 argument_expression_list: 702 argument_expression 696 703 | argument_expression_list_opt ',' argument_expression 697 704 { $$ = (ExpressionNode *)($1->set_last( $3 )); } … … 731 738 | FLOATINGconstant fraction_constants_opt 732 739 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 733 | identifier fraction_constants_opt740 | identifier_at fraction_constants_opt // CFA, allow anonymous fields 734 741 { 735 742 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 1084 1091 comma_expression_opt ';' 1085 1092 { $$ = 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; } 1086 1096 ; 1087 1097 … … 1182 1192 1183 1193 iteration_statement: 1184 WHILE '(' push if_control_expression ')' statement pop 1185 { $$ = new StatementNode( build_while( $4, maybe_build_compound( $6 ) ) ); } 1186 | WHILE '(' ')' statement // CFA => while ( 1 ) 1194 WHILE '(' ')' statement // CFA => while ( 1 ) 1187 1195 { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); } 1188 | DO statement WHILE '(' comma_expression ')' ';' 1189 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); } 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; } 1190 1200 | DO statement WHILE '(' ')' ';' // CFA => do while( 1 ) 1191 1201 { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); } 1192 | FOR '(' push for_control_expression_list ')' statement pop 1193 { $$ = new StatementNode( build_for( $4, maybe_build_compound( $6 ) ) ); } 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; } 1194 1206 | FOR '(' ')' statement // CFA => for ( ;; ) 1195 1207 { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); } 1208 | FOR '(' for_control_expression_list ')' statement %prec THEN 1209 { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); } 1210 | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA 1211 { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; } 1196 1212 ; 1197 1213 … … 1339 1355 with_statement: 1340 1356 WITH '(' tuple_expression_list ')' statement 1341 { 1342 $$ = new StatementNode( build_with( $3, $5 ) ); 1343 } 1357 { $$ = new StatementNode( build_with( $3, $5 ) ); } 1344 1358 ; 1345 1359 1346 1360 // If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex". 1347 1361 mutex_statement: 1348 MUTEX '(' argument_expression_list _opt')' statement1362 MUTEX '(' argument_expression_list ')' statement 1349 1363 { $$ = new StatementNode( build_mutex( $3, $5 ) ); } 1350 1364 ; … … 2475 2489 designation: 2476 2490 designator_list ':' // C99, CFA uses ":" instead of "=" 2477 | identifier ':' // GCC, field name2491 | identifier_at ':' // GCC, field name 2478 2492 { $$ = new ExpressionNode( build_varref( $1 ) ); } 2479 2493 ; … … 2487 2501 2488 2502 designator: 2489 '.' identifier 2503 '.' identifier_at // C99, field name 2490 2504 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2491 2505 | '[' push assignment_expression pop ']' // C99, single array element … … 2919 2933 2920 2934 paren_identifier: 2921 identifier 2935 identifier_at 2922 2936 { $$ = DeclarationNode::newName( $1 ); } 2923 2937 | '(' paren_identifier ')' // redundant parenthesis
Note: See TracChangeset
for help on using the changeset viewer.