- Timestamp:
- Feb 19, 2022, 9:48:04 AM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 1eec0b0
- Parents:
- a38bbbc
- git-author:
- Peter A. Buhr <pabuhr@…> (02/19/22 09:15:38)
- git-committer:
- Peter A. Buhr <pabuhr@…> (02/19/22 09:48:04)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
ra38bbbc r5c216b4 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 11 14:26:15202213 // Update Count : 5 17412 // Last Modified On : Sat Feb 19 09:47:20 2022 13 // Update Count : 5218 14 14 // 15 15 … … 1052 1052 identifier_or_type_name ':' attribute_list_opt statement 1053 1053 { $$ = $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; } 1054 1056 ; 1055 1057 … … 1086 1088 | statement_list_nodecl statement 1087 1089 { 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; } 1088 1092 ; 1089 1093 … … 1093 1097 | MUTEX '(' ')' comma_expression ';' 1094 1098 { $$ = new StatementNode( build_mutex( nullptr, new StatementNode( build_expr( $4 ) ) ) ); } 1095 // { SemanticError( yylloc, "Mutex expression is currently unimplemented." ); $$ = nullptr; }1096 1099 ; 1097 1100 … … 1113 1116 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 1114 1117 } 1118 | SWITCH '(' comma_expression ')' '{' error '}' // CFA 1119 { SemanticError( yylloc, "only declarations can appear before the list of case clauses." ); $$ = nullptr; } 1115 1120 | CHOOSE '(' comma_expression ')' case_clause // CFA 1116 1121 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); } … … 1120 1125 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 1121 1126 } 1127 | CHOOSE '(' comma_expression ')' '{' error '}' // CFA 1128 { SemanticError( yylloc, "only declarations can appear before the list of case clauses." ); $$ = nullptr; } 1122 1129 ; 1123 1130 … … 1158 1165 1159 1166 case_label: // CFA 1160 CASE case_value_list ':' { $$ = $2; } 1167 CASE error 1168 { SemanticError( yylloc, "missing case list after case." ); $$ = nullptr; } 1169 | CASE case_value_list ':' { $$ = $2; } 1170 | CASE case_value_list error 1171 { SemanticError( yylloc, "missing colon after case list." ); $$ = nullptr; } 1161 1172 | DEFAULT ':' { $$ = new StatementNode( build_default() ); } 1162 1173 // A semantic check is required to ensure only one default clause per switch/choose statement. 1163 ; 1164 1165 //label_list_opt: 1166 // // empty 1167 // | identifier_or_type_name ':' 1168 // | label_list_opt identifier_or_type_name ':' 1169 // ; 1174 | DEFAULT error 1175 { SemanticError( yylloc, "missing colon after default." ); $$ = nullptr; } 1176 ; 1170 1177 1171 1178 case_label_list: // CFA
Note: See TracChangeset
for help on using the changeset viewer.