Changeset afe9e45
- Timestamp:
- Feb 25, 2022, 6:19:16 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 41870a5
- Parents:
- 08ed947
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r08ed947 rafe9e45 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 19 09:47:20202213 // Update Count : 52 1812 // Last Modified On : Fri Feb 25 17:54:56 2022 13 // Update Count : 5262 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 error 613 { 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 error 621 { 622 SemanticError( yylloc, ::toString( "Identifier \"", *$1.str, "\" cannot appear before a type. " 623 "Possible problem is misspelled storage or CV qualifier." ) ); 624 $$ = nullptr; 625 } 612 626 ; 613 627 … … 1052 1066 identifier_or_type_name ':' attribute_list_opt statement 1053 1067 { $$ = $4->add_label( $1, $3 ); } 1054 | identifier_or_type_name ':' attribute_list_opt error 1055 { SemanticError( yylloc, "previous label must be associated with a statement (where a declaration is not a statement). Move the label or terminate with a semi-colon." ); $$ = nullptr; } 1068 | identifier_or_type_name ':' attribute_list_opt error // syntax error 1069 { 1070 SemanticError( yylloc, ::toString( "Label \"", *$1.str, "\" must be associated with a statement, " 1071 "where a declaration, case, or default is not a statement. " 1072 "Move the label or terminate with a semi-colon." ) ); 1073 $$ = nullptr; 1074 } 1056 1075 ; 1057 1076 … … 1088 1107 | statement_list_nodecl statement 1089 1108 { assert( $1 ); $1->set_last( $2 ); $$ = $1; } 1090 | statement_list_nodecl error 1091 { SemanticError( yylloc, " declarations only allowed at the start of the switch body, i.e., after the '{'." ); $$ = nullptr; }1109 | statement_list_nodecl error // syntax error 1110 { SemanticError( yylloc, "Declarations only allowed at the start of the switch body, i.e., after the '{'." ); $$ = nullptr; } 1092 1111 ; 1093 1112 … … 1116 1135 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 1117 1136 } 1118 | SWITCH '(' comma_expression ')' '{' error '}' // CFA 1119 { SemanticError( yylloc, " only declarations can appear before the list of case clauses." ); $$ = nullptr; }1137 | SWITCH '(' comma_expression ')' '{' error '}' // CFA, syntax error 1138 { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; } 1120 1139 | CHOOSE '(' comma_expression ')' case_clause // CFA 1121 1140 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); } … … 1125 1144 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 1126 1145 } 1127 | CHOOSE '(' comma_expression ')' '{' error '}' // CFA 1128 { SemanticError( yylloc, " only declarations can appear before the list of case clauses." ); $$ = nullptr; }1146 | CHOOSE '(' comma_expression ')' '{' error '}' // CFA, syntax error 1147 { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; } 1129 1148 ; 1130 1149 … … 1165 1184 1166 1185 case_label: // CFA 1167 CASE error 1168 { SemanticError( yylloc, " missing case list after case." ); $$ = nullptr; }1186 CASE error // syntax error 1187 { SemanticError( yylloc, "Missing case list after case." ); $$ = nullptr; } 1169 1188 | CASE case_value_list ':' { $$ = $2; } 1170 | CASE case_value_list error 1171 { SemanticError( yylloc, " missing colon after case list." ); $$ = nullptr; }1189 | CASE case_value_list error // syntax error 1190 { SemanticError( yylloc, "Missing colon after case list." ); $$ = nullptr; } 1172 1191 | DEFAULT ':' { $$ = new StatementNode( build_default() ); } 1173 1192 // A semantic check is required to ensure only one default clause per switch/choose statement. 1174 | DEFAULT error 1175 { SemanticError( yylloc, " missing colon after default." ); $$ = nullptr; }1193 | DEFAULT error // syntax error 1194 { SemanticError( yylloc, "Missing colon after default." ); $$ = nullptr; } 1176 1195 ; 1177 1196 … … 1410 1429 | when_clause_opt ELSE statement 1411 1430 { $$ = build_waitfor_timeout( nullptr, maybe_build_compound( $3 ), $1 ); } 1412 1413 | when_clause_opt timeout statement WOR ELSE statement 1431 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1432 | when_clause_opt timeout statement WOR ELSE statement // syntax error 1414 1433 { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; } 1415 1434 | when_clause_opt timeout statement WOR when_clause ELSE statement
Note: See TracChangeset
for help on using the changeset viewer.