Changes in src/Parser/parser.yy [d824715:aac37fa]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rd824715 raac37fa 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 14 16:35:29202213 // Update Count : 5 27612 // Last Modified On : Fri Feb 11 14:26:15 2022 13 // Update Count : 5174 14 14 // 15 15 … … 610 610 // | RESUME '(' comma_expression ')' compound_statement 611 611 // { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; } 612 | IDENTIFIER IDENTIFIER // syntax error613 {614 SemanticError( yylloc, ::toString( "Adjacent identifiers are not meaningful in an expression. "615 "Possible problem is identifier \"", *$1.str,616 "\" is a misspelled typename or an incorrectly specified type name, "617 "e.g., missing generic parameter or missing struct/union/enum before typename." ) );618 $$ = nullptr;619 }620 | IDENTIFIER direct_type // syntax error621 {622 SemanticError( yylloc, ::toString( "Identifier \"", *$1.str, "\" cannot appear before a type. "623 "Possible problem is misspelled storage or CV qualifier." ) );624 $$ = nullptr;625 }626 612 ; 627 613 … … 652 638 // Historic, transitional: Disallow commas in subscripts. 653 639 // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts. 640 // { SemanticError( yylloc, "New array subscript is currently unimplemented." ); $$ = nullptr; } 654 641 // Current: Commas in subscripts make tuples. 655 642 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); } … … 660 647 // equivalent to the old x[i,j]. 661 648 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); } 662 | constant '[' assignment_expression ']' // 3[a], 'a'[a], 3.5[a]663 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }664 | string_literal '[' assignment_expression ']' // "abc"[3], 3["abc"]665 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); }666 649 | postfix_expression '{' argument_expression_list_opt '}' // CFA, constructor call 667 650 { … … 1069 1052 identifier_or_type_name ':' attribute_list_opt statement 1070 1053 { $$ = $4->add_label( $1, $3 ); } 1071 | identifier_or_type_name ':' attribute_list_opt error // syntax error1072 {1073 SemanticError( yylloc, ::toString( "Label \"", *$1.str, "\" must be associated with a statement, "1074 "where a declaration, case, or default is not a statement. "1075 "Move the label or terminate with a semi-colon." ) );1076 $$ = nullptr;1077 }1078 1054 ; 1079 1055 … … 1110 1086 | statement_list_nodecl statement 1111 1087 { assert( $1 ); $1->set_last( $2 ); $$ = $1; } 1112 | statement_list_nodecl error // syntax error1113 { SemanticError( yylloc, "Declarations only allowed at the start of the switch body, i.e., after the '{'." ); $$ = nullptr; }1114 1088 ; 1115 1089 … … 1119 1093 | MUTEX '(' ')' comma_expression ';' 1120 1094 { $$ = new StatementNode( build_mutex( nullptr, new StatementNode( build_expr( $4 ) ) ) ); } 1095 // { SemanticError( yylloc, "Mutex expression is currently unimplemented." ); $$ = nullptr; } 1121 1096 ; 1122 1097 … … 1138 1113 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 1139 1114 } 1140 | SWITCH '(' comma_expression ')' '{' error '}' // CFA, syntax error1141 { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; }1142 1115 | CHOOSE '(' comma_expression ')' case_clause // CFA 1143 1116 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); } … … 1147 1120 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 1148 1121 } 1149 | CHOOSE '(' comma_expression ')' '{' error '}' // CFA, syntax error1150 { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; }1151 1122 ; 1152 1123 … … 1187 1158 1188 1159 case_label: // CFA 1189 CASE error // syntax error 1190 { SemanticError( yylloc, "Missing case list after case." ); $$ = nullptr; } 1191 | CASE case_value_list ':' { $$ = $2; } 1192 | CASE case_value_list error // syntax error 1193 { SemanticError( yylloc, "Missing colon after case list." ); $$ = nullptr; } 1160 CASE case_value_list ':' { $$ = $2; } 1194 1161 | DEFAULT ':' { $$ = new StatementNode( build_default() ); } 1195 1162 // A semantic check is required to ensure only one default clause per switch/choose statement. 1196 | DEFAULT error // syntax error 1197 { SemanticError( yylloc, "Missing colon after default." ); $$ = nullptr; } 1198 ; 1163 ; 1164 1165 //label_list_opt: 1166 // // empty 1167 // | identifier_or_type_name ':' 1168 // | label_list_opt identifier_or_type_name ':' 1169 // ; 1199 1170 1200 1171 case_label_list: // CFA … … 1432 1403 | when_clause_opt ELSE statement 1433 1404 { $$ = build_waitfor_timeout( nullptr, maybe_build_compound( $3 ), $1 ); } 1434 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)1435 | when_clause_opt timeout statement WOR ELSE statement // syntax error1405 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1406 | when_clause_opt timeout statement WOR ELSE statement 1436 1407 { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; } 1437 1408 | when_clause_opt timeout statement WOR when_clause ELSE statement
Note:
See TracChangeset
for help on using the changeset viewer.