Changeset 1a8b17a
- Timestamp:
- Oct 13, 2024, 12:22:26 PM (6 weeks ago)
- Branches:
- master
- Children:
- 1a7203d
- Parents:
- 0766399
- Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
r0766399 r1a8b17a 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Mon Sep 23 22:45:33202413 * Update Count : 79212 * Last Modified On : Sun Oct 13 10:03:28 2024 13 * Update Count : 869 14 14 */ 15 15 … … 147 147 // character escape sequence, GCC: \e => esc character 148 148 simple_escape "\\"[abefnrtv'"?\\] 149 // 'stop editor highlighting149 // " stop editor highlighting 150 150 octal_escape "\\"{octal}("_"?{octal}){0,2} 151 151 hex_escape "\\""x""_"?{hex_digits} … … 155 155 156 156 // display/white-space characters 157 h_tab [\011] 158 form_feed [\014] 159 v_tab [\013] 160 c_return [\015] 161 h_white [ ]|{h_tab} 157 h_tab "\t" 158 form_feed "\f" 159 v_tab "\v" 160 new_line "\n" 161 c_return "\r" 162 h_white " "|{h_tab} 163 v_white {v_tab}|{c_return}|{form_feed} 164 hv_white {h_white}|{v_tab}|{new_line}|{c_return}|{form_feed} 162 165 163 166 // overloadable operators … … 171 174 // op_binary_not_over "?"|"->"|"."|"&&"|"||"|"@=" 172 175 // operator {op_unary_pre_post}|{op_binary_over}|{op_binary_not_over} 176 177 // C23 attributes 178 attr_string "\""[^\"]*"\"" 179 attr_arg_opt ({hv_white}*"("{hv_white}*{attr_string}{hv_white}*")")? 180 attributes "deprecated"{attr_arg_opt}|"fallthrough"|"nodiscard"{attr_arg_opt}|"maybe_unused"|"noreturn"|"_Noreturn"|"unsequenced"|"unused"|"reproducible"|{identifier}{hv_white}*"::"{hv_white}*{identifier} 173 181 174 182 %x COMMENT … … 212 220 213 221 /* ignore whitespace */ 214 {h_white}+ { WHITE_RETURN(' '); } 215 ({v_tab}|{c_return}|{form_feed})+ { WHITE_RETURN(' '); } 216 ({h_white}|{v_tab}|{c_return}|{form_feed})*"\n" { NEWLINE_RETURN(); } 222 ({h_white}|{v_white})+ { WHITE_RETURN(' '); } // do nothing 223 "\n" { NEWLINE_RETURN(); } // reset column counter 217 224 218 225 /* keywords */ … … 373 380 } 374 381 382 /* C23 attributes */ 383 "[["{hv_white}*{attributes}({hv_white}*","{hv_white}*{attributes})*{hv_white}*"]]" { 384 strtext = new string( &yytext[2], yyleng - 4 ); // remove [[]] 385 RETURN_STR(C23_ATTRIBUTE); 386 } 387 375 388 /* numeric constants */ 376 389 {binary_constant} { NUMERIC_RETURN(INTEGERconstant); } 377 390 {octal_constant} { NUMERIC_RETURN(INTEGERconstant); } 378 391 {decimal_constant} { NUMERIC_RETURN(INTEGERconstant); } 379 {hex_constant} 380 {floating_decimal} 392 {hex_constant} { NUMERIC_RETURN(INTEGERconstant); } 393 {floating_decimal} { NUMERIC_RETURN(FLOATING_DECIMALconstant); } // must appear before floating_constant 381 394 {floating_fraction} { NUMERIC_RETURN(FLOATING_FRACTIONconstant); } // must appear before floating_constant 382 395 {floating_constant} { NUMERIC_RETURN(FLOATINGconstant); } -
src/Parser/parser.yy
r0766399 r1a8b17a 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 30 09:40:28202413 // Update Count : 6 77612 // Last Modified On : Sun Oct 13 12:18:15 2024 13 // Update Count : 6845 14 14 // 15 15 … … 392 392 %token<tok> TIMEOUT WAND WOR CATCH RECOVER CATCHRESUME FIXUP FINALLY // CFA 393 393 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 394 %token<tok> DIRECTIVE 394 %token<tok> DIRECTIVE C23_ATTRIBUTE 395 395 // Floating point constant is broken into three kinds of tokens because of the ambiguity with tuple indexing and 396 396 // overloading constants 0/1, e.g., x.1 is lexed as (x)(.1), where (.1) is a factional constant, but is semantically … … 1169 1169 // CFA, one assignment_expression is factored out of comma_expression to eliminate a shift/reduce conflict with 1170 1170 // comma_expression in cfa_identifier_parameter_array and cfa_abstract_array 1171 // '[' ']'1172 // { $$ = new ExpressionNode( build_tuple() ); }1173 // '[' assignment_expression']'1174 // { $$ = new ExpressionNode( build_tuple($2 ) ); }1175 '[' ',' tuple_expression_list ']'1176 { $$ = new ExpressionNode( build_tuple( yylloc, (new ExpressionNode( nullptr ))->set_last( $3 ) ) ); }1177 | '[' assignment_expression ',' tuple_expression_list ']'1171 '[' ',' ']' 1172 { $$ = new ExpressionNode( build_tuple( yylloc, nullptr ) ); } 1173 | '[' assignment_expression ',' ']' 1174 { $$ = new ExpressionNode( build_tuple( yylloc, $2 ) ); } 1175 | '[' '@' comma_opt ']' 1176 { SemanticError( yylloc, "Eliding tuple element with '@' is currently unimplemented." ); $$ = nullptr; } 1177 | '[' assignment_expression ',' tuple_expression_list comma_opt ']' 1178 1178 { $$ = new ExpressionNode( build_tuple( yylloc, $2->set_last( $4 ) ) ); } 1179 | '[' '@' ',' tuple_expression_list comma_opt ']' 1180 { SemanticError( yylloc, "Eliding tuple element with '@' is currently unimplemented." ); $$ = nullptr; } 1179 1181 ; 1180 1182 … … 3050 3052 3051 3053 designation: 3052 designator_list ' :' // C99, CFA uses ":" instead of "="3053 | identifier_at ':' // GCC, field name 3054 designator_list '=' // C99, CFA uses ":" instead of "=" 3055 | identifier_at ':' // GCC, field name, obsolete since GCC 2.5 3054 3056 { $$ = new ExpressionNode( build_varref( yylloc, $1 ) ); } 3055 3057 ; … … 3059 3061 | designator_list designator 3060 3062 { $$ = $1->set_last( $2 ); } 3061 //| designator_list designator { $$ = new ExpressionNode( $1, $2 ); }3062 3063 ; 3063 3064 … … 3065 3066 '.' identifier_at // C99, field name 3066 3067 { $$ = new ExpressionNode( build_varref( yylloc, $2 ) ); } 3067 | '[' assignment_expression ']' // C99, single array element 3068 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. 3068 | '[' constant_expression ']' // C99, single array element 3069 3069 { $$ = $2; } 3070 3070 | '[' subrange ']' // CFA, multiple array elements … … 3513 3513 | ATTR '(' attribute_name_list ')' // CFA 3514 3514 { $$ = $3; } 3515 | C23_ATTRIBUTE 3516 { $$ = DeclarationNode::newAttribute( $1 ); } 3515 3517 ; 3516 3518
Note: See TracChangeset
for help on using the changeset viewer.