Changeset 1cdfa82 for src/Parser
- Timestamp:
- Apr 25, 2018, 4:55:53 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 42107b4
- Parents:
- 2efe4b8 (diff), 9d5fb67 (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. - Location:
- src/Parser
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r2efe4b8 r1cdfa82 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 22 15:37:17201813 // Update Count : 10 3312 // Last Modified On : Fri Apr 20 22:37:20 2018 13 // Update Count : 1063 14 14 // 15 15 … … 47 47 const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" }; 48 48 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" }; 49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", " NoBuiltinTypeNames" };49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "zero_t", "one_t", "NoBuiltinTypeNames" }; 50 50 51 51 UniqueName DeclarationNode::anonymous( "__anonymous" ); … … 71 71 attr.expr = nullptr; 72 72 attr.type = nullptr; 73 74 assert.condition = nullptr; 75 assert.message = nullptr; 73 76 } 74 77 … … 88 91 // asmName, no delete, passed to next stage 89 92 delete initializer; 93 94 delete assert.condition; 95 delete assert.message; 90 96 } 91 97 … … 117 123 newnode->attr.expr = maybeClone( attr.expr ); 118 124 newnode->attr.type = maybeClone( attr.type ); 125 126 newnode->assert.condition = maybeClone( assert.condition ); 127 newnode->assert.message = maybeClone( assert.message ); 119 128 return newnode; 120 129 } // DeclarationNode::clone … … 434 443 return newnode; 435 444 } 445 446 DeclarationNode * DeclarationNode::newStaticAssert( ExpressionNode * condition, Expression * message ) { 447 DeclarationNode * newnode = new DeclarationNode; 448 newnode->assert.condition = condition; 449 newnode->assert.message = message; 450 return newnode; 451 } 452 436 453 437 454 void appendError( string & dst, const string & src ) { … … 544 561 545 562 checkQualifiers( type, q->type ); 563 if ( (builtin == Zero || builtin == One) && error.length() == 0 ) { 564 SemanticWarning( yylloc, Warning::BadQualifiersZeroOne, Type::QualifiersNames[ilog2( q->type->qualifiers.val )], builtinTypeNames[builtin] ); 565 // appendError( error, string( "questionable qualifiers" ) ); 566 } // if 546 567 addQualifiersToType( q->type, type ); 547 568 … … 907 928 delete newType->aggInst.aggregate->enumeration.constants; 908 929 newType->aggInst.aggregate->enumeration.constants = nullptr; 930 newType->aggInst.aggregate->enumeration.body = false; 909 931 } else { 910 932 assert( newType->aggInst.aggregate->kind == TypeData::Aggregate ); 911 933 delete newType->aggInst.aggregate->aggregate.fields; 912 934 newType->aggInst.aggregate->aggregate.fields = nullptr; 935 newType->aggInst.aggregate->aggregate.body = false; 913 936 } // if 914 937 // don't hoist twice … … 1051 1074 } // if 1052 1075 1076 if ( assert.condition ) { 1077 return new StaticAssertDecl( maybeBuild< Expression >( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) ); 1078 } 1079 1053 1080 // SUE's cannot have function specifiers, either 1054 1081 // -
src/Parser/ExpressionNode.cc
r2efe4b8 r1cdfa82 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 3 18:22:33201813 // Update Count : 79612 // Last Modified On : Thu Mar 22 11:57:39 2018 13 // Update Count : 801 14 14 // 15 15 … … 94 94 } // checkLNInt 95 95 96 static void sepNumeric( string & str, string & units ) {97 string::size_type posn = str.find_first_of( "`" );98 if ( posn != string::npos ) {99 units = "?" + str.substr( posn ); // extract units100 str.erase( posn ); // remove units101 } // if102 } // sepNumeric103 104 96 Expression * build_constantInteger( string & str ) { 105 97 static const BasicType::Kind kind[2][6] = { … … 108 100 { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, }, 109 101 }; 110 111 string units;112 sepNumeric( str, units ); // separate constant from units113 102 114 103 bool dec = true, Unsigned = false; // decimal, unsigned constant … … 222 211 if ( Unsigned && size < 2 ) { // hh or h, less than int ? 223 212 // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values. 224 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );213 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false ); 225 214 } else if ( lnth != -1 ) { // explicit length ? 226 215 if ( lnth == 5 ) { // int128 ? 227 216 size = 5; 228 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );217 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ), false ); 229 218 } else { 230 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ) );219 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][lnth], false ), false ); 231 220 } // if 232 221 } // if 233 222 CLEANUP: 234 if ( units.length() != 0 ) {235 ret = new UntypedExpr( new NameExpr( units ), { ret } );236 } // if237 223 238 224 delete &str; // created by lex … … 268 254 }; 269 255 270 string units;271 sepNumeric( str, units ); // separate constant from units272 273 256 bool complx = false; // real, complex 274 257 int size = 1; // 0 => float, 1 => double, 2 => long double … … 302 285 Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) ); 303 286 if ( lnth != -1 ) { // explicit length ? 304 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ) ); 305 } // if 306 if ( units.length() != 0 ) { 307 ret = new UntypedExpr( new NameExpr( units ), { ret } ); 287 ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][size] ), false ); 308 288 } // if 309 289 … … 427 407 Type * targetType = maybeMoveBuildType( decl_node ); 428 408 if ( dynamic_cast< VoidType * >( targetType ) ) { 429 return new CastExpr( maybeMoveBuild< Expression >(expr_node) );409 return new CastExpr( maybeMoveBuild< Expression >(expr_node), false ); 430 410 } else { 431 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );411 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType, false ); 432 412 } // if 433 413 } // build_cast 414 415 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) { 416 return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target ); 417 } 434 418 435 419 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) { -
src/Parser/ParseNode.h
r2efe4b8 r1cdfa82 179 179 180 180 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 181 Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ); 181 182 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 182 183 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); … … 246 247 static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes 247 248 static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement 249 static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message ); 248 250 249 251 DeclarationNode(); … … 313 315 Attr_t attr; 314 316 317 struct StaticAssert_t { 318 ExpressionNode * condition; 319 Expression * message; 320 }; 321 StaticAssert_t assert; 322 315 323 BuiltinType builtin; 316 324 … … 392 400 393 401 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ); 394 Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt );402 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ); 395 403 Statement * build_case( ExpressionNode * ctl ); 396 404 Statement * build_default(); -
src/Parser/StatementNode.cc
r2efe4b8 r1cdfa82 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Sep 1 23:25:23 201713 // Update Count : 34 612 // Last Modified On : Thu Mar 8 14:31:32 2018 13 // Update Count : 348 14 14 // 15 15 … … 115 115 } 116 116 117 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {117 Statement *build_switch( bool isSwitch, ExpressionNode *ctl, StatementNode *stmt ) { 118 118 std::list< Statement * > branches; 119 119 buildMoveList< Statement, StatementNode >( stmt, branches ); 120 if ( ! isSwitch ) { // choose statement 121 for ( Statement * stmt : branches ) { 122 CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt ); 123 if ( ! caseStmt->stmts.empty() ) { // code after "case" => end of case list 124 CompoundStmt * block = strict_dynamic_cast< CompoundStmt * >( caseStmt->stmts.front() ); 125 block->kids.push_back( new BranchStmt( "", BranchStmt::Break ) ); 126 } // if 127 } // for 128 } // if 120 129 // branches.size() == 0 for switch (...) {}, i.e., no declaration or statements 121 130 return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches ); -
src/Parser/TypeData.cc
r2efe4b8 r1cdfa82 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 22 15:49:00201813 // Update Count : 59712 // Last Modified On : Tue Apr 17 23:00:52 2018 13 // Update Count : 602 14 14 // 15 15 … … 395 395 break; 396 396 case Builtin: 397 os << "gcc builtin type";397 os << DeclarationNode::builtinTypeNames[builtintype]; 398 398 break; 399 399 default: … … 490 490 switch ( td->kind ) { 491 491 case TypeData::Aggregate: 492 if ( ! toplevel && td->aggregate. fields) {492 if ( ! toplevel && td->aggregate.body ) { 493 493 ret = td->clone(); 494 494 } // if 495 495 break; 496 496 case TypeData::Enum: 497 if ( ! toplevel && td->enumeration. constants) {497 if ( ! toplevel && td->enumeration.body ) { 498 498 ret = td->clone(); 499 499 } // if -
src/Parser/lex.ll
r2efe4b8 r1cdfa82 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Sat Mar 3 18:38:16201813 * Update Count : 6 4012 * Last Modified On : Fri Apr 6 15:16:15 2018 13 * Update Count : 670 14 14 */ 15 15 … … 54 54 55 55 void rm_underscore() { 56 // Remove underscores in numeric constant by copying the non-underscore characters to the front of the string.56 // SKULLDUGGERY: remove underscores (ok to shorten?) 57 57 yyleng = 0; 58 for ( int i = 0; yytext[i] != '\0'; i += 1 ) { 59 if ( yytext[i] == '`' ) { 60 // copy user suffix 61 for ( ; yytext[i] != '\0'; i += 1 ) { 62 yytext[yyleng] = yytext[i]; 63 yyleng += 1; 64 } // for 65 break; 66 } // if 58 for ( int i = 0; yytext[i] != '\0'; i += 1 ) { // copying non-underscore characters to front of string 67 59 if ( yytext[i] != '_' ) { 68 60 yytext[yyleng] = yytext[i]; … … 71 63 } // for 72 64 yytext[yyleng] = '\0'; 73 } 65 } // rm_underscore 74 66 75 67 // Stop warning due to incorrectly generated flex code. … … 90 82 attr_identifier "@"{identifier} 91 83 92 user_suffix_opt ("`"{identifier})?93 94 84 // numeric constants, CFA: '_' in constant 95 85 hex_quad {hex}("_"?{hex}){3} 96 86 size_opt (8|16|32|64|128)? 97 87 length ("ll"|"LL"|[lL]{size_opt})|("hh"|"HH"|[hH]) 98 integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))? {user_suffix_opt}88 integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))? 99 89 100 90 octal_digits ({octal})|({octal}({octal}|"_")*{octal}) … … 118 108 floating_length ([fFdDlL]|[lL]{floating_size}) 119 109 floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length}) 120 floating_suffix_opt ("_"?({floating_suffix}|"DL"))? {user_suffix_opt}110 floating_suffix_opt ("_"?({floating_suffix}|"DL"))? 121 111 decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal}) 122 112 floating_decimal {decimal_digits}"."{exponent}?{floating_suffix_opt} … … 125 115 126 116 binary_exponent "_"?[pP]"_"?[+-]?{decimal_digits} 127 hex_floating_suffix_opt ("_"?({floating_suffix}))? {user_suffix_opt}117 hex_floating_suffix_opt ("_"?({floating_suffix}))? 128 118 hex_floating_fraction ({hex_digits}?"."{hex_digits})|({hex_digits}".") 129 119 hex_floating_constant {hex_prefix}(({hex_floating_fraction}{binary_exponent})|({hex_digits}{binary_exponent})){hex_floating_suffix_opt} … … 208 198 __asm { KEYWORD_RETURN(ASM); } // GCC 209 199 __asm__ { KEYWORD_RETURN(ASM); } // GCC 210 _At { KEYWORD_RETURN(AT); } // CFA211 200 _Atomic { KEYWORD_RETURN(ATOMIC); } // C11 212 201 __attribute { KEYWORD_RETURN(ATTRIBUTE); } // GCC … … 239 228 exception { KEYWORD_RETURN(EXCEPTION); } // CFA 240 229 extern { KEYWORD_RETURN(EXTERN); } 230 fallthrough { KEYWORD_RETURN(FALLTHROUGH); } // CFA 241 231 fallthru { KEYWORD_RETURN(FALLTHRU); } // CFA 242 fallthrough { KEYWORD_RETURN(FALLTHROUGH); } // CFA243 232 finally { KEYWORD_RETURN(FINALLY); } // CFA 244 233 float { KEYWORD_RETURN(FLOAT); } … … 270 259 __builtin_offsetof { KEYWORD_RETURN(OFFSETOF); } // GCC 271 260 one_t { NUMERIC_RETURN(ONE_T); } // CFA 261 or { QKEYWORD_RETURN(WOR); } // CFA 272 262 otype { KEYWORD_RETURN(OTYPE); } // CFA 273 263 register { KEYWORD_RETURN(REGISTER); } … … 306 296 __volatile__ { KEYWORD_RETURN(VOLATILE); } // GCC 307 297 waitfor { KEYWORD_RETURN(WAITFOR); } 308 or { QKEYWORD_RETURN(WOR); } // CFA309 298 when { KEYWORD_RETURN(WHEN); } 310 299 while { KEYWORD_RETURN(WHILE); } … … 314 303 /* identifier */ 315 304 {identifier} { IDENTIFIER_RETURN(); } 305 "`"{identifier}"`" { // CFA 306 yytext[yyleng - 1] = '\0'; yytext += 1; // SKULLDUGGERY: remove backquotes (ok to shorten?) 307 IDENTIFIER_RETURN(); 308 } 316 309 {attr_identifier} { ATTRIBUTE_RETURN(); } 317 "`" { BEGIN BKQUOTE; }318 <BKQUOTE>{identifier} { IDENTIFIER_RETURN(); }319 <BKQUOTE>"`" { BEGIN 0; }320 310 321 311 /* numeric constants */ … … 332 322 ({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new string( yytext, yyleng ); } 333 323 <QUOTE>[^'\\\n]* { strtext->append( yytext, yyleng ); } 334 <QUOTE>['\n] {user_suffix_opt}{ BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); }324 <QUOTE>['\n] { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(CHARACTERconstant); } 335 325 /* ' stop editor highlighting */ 336 326 … … 338 328 ({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new string( yytext, yyleng ); } 339 329 <STRING>[^"\\\n]* { strtext->append( yytext, yyleng ); } 340 <STRING>["\n] {user_suffix_opt}{ BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); }330 <STRING>["\n] { BEGIN 0; strtext->append( yytext, yyleng ); RETURN_STR(STRINGliteral); } 341 331 /* " stop editor highlighting */ 342 332 … … 348 338 /* punctuation */ 349 339 "@" { ASCIIOP_RETURN(); } 340 "`" { ASCIIOP_RETURN(); } 350 341 "[" { ASCIIOP_RETURN(); } 351 342 "]" { ASCIIOP_RETURN(); } … … 412 403 "?"({op_unary_pre_post}|"()"|"[?]"|"{}") { IDENTIFIER_RETURN(); } 413 404 "^?{}" { IDENTIFIER_RETURN(); } 414 "?`"{identifier} { IDENTIFIER_RETURN(); } // unitoperator405 "?`"{identifier} { IDENTIFIER_RETURN(); } // postfix operator 415 406 "?"{op_binary_over}"?" { IDENTIFIER_RETURN(); } // binary 416 407 /* -
src/Parser/parser.yy
r2efe4b8 r1cdfa82 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 22 17:48:54201813 // Update Count : 3 02812 // Last Modified On : Tue Apr 17 17:10:30 2018 13 // Update Count : 3144 14 14 // 15 15 … … 126 126 } // if 127 127 } // rebindForall 128 129 NameExpr * build_postfix_name( const string * name ) { 130 NameExpr * new_name = build_varref( new string( "?`" + *name ) ); 131 delete name; 132 return new_name; 133 } // build_postfix_name 128 134 129 135 bool forall = false; // aggregate have one or more forall qualifiers ? … … 254 260 %type<sn> statement_decl statement_decl_list statement_list_nodecl 255 261 %type<sn> selection_statement 256 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list262 %type<sn> switch_clause_list_opt switch_clause_list 257 263 %type<en> case_value 258 264 %type<sn> case_clause case_value_list case_label case_label_list 259 %type<sn> fall_through fall_through_opt260 265 %type<sn> iteration_statement jump_statement 261 266 %type<sn> expression_statement asm_statement … … 386 391 %precedence '(' 387 392 388 %locations // support location tracking for error messages393 %locations // support location tracking for error messages 389 394 390 395 %start translation_unit // parse-tree root … … 481 486 | '(' compound_statement ')' // GCC, lambda expression 482 487 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); } 488 | constant '`' IDENTIFIER // CFA, postfix call 489 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 490 | string_literal '`' IDENTIFIER // CFA, postfix call 491 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); } 492 | IDENTIFIER '`' IDENTIFIER // CFA, postfix call 493 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); } 494 | tuple '`' IDENTIFIER // CFA, postfix call 495 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); } 496 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 497 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 483 498 | type_name '.' no_attr_identifier // CFA, nested type 484 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME499 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 485 500 | type_name '.' '[' push field_list pop ']' // CFA, nested type / tuple field selector 486 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME501 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } 487 502 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 488 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME503 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } 489 504 ; 490 505 … … 535 550 | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal 536 551 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 552 | '(' type_no_function ')' '@' '{' initializer_list comma_opt '}' // CFA, explicit C compound-literal 553 { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); } 537 554 | '^' primary_expression '{' argument_expression_list '}' // CFA 538 555 { … … 670 687 | '(' type_no_function ')' cast_expression 671 688 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 689 | '(' COROUTINE '&' ')' cast_expression // CFA 690 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); } 691 | '(' THREAD '&' ')' cast_expression // CFA 692 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); } 693 | '(' MONITOR '&' ')' cast_expression // CFA 694 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); } 672 695 // VIRTUAL cannot be opt because of look ahead issues 673 | '(' VIRTUAL ')' cast_expression 696 | '(' VIRTUAL ')' cast_expression // CFA 674 697 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); } 675 | '(' VIRTUAL type_no_function ')' cast_expression 698 | '(' VIRTUAL type_no_function ')' cast_expression // CFA 676 699 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); } 677 700 // | '(' type_no_function ')' tuple … … 765 788 | logical_OR_expression '?' comma_expression ':' conditional_expression 766 789 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 767 // FIX ME: this hackcomputes $1 twice790 // FIX ME: computes $1 twice 768 791 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 769 792 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } … … 780 803 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); } 781 804 | unary_expression '=' '{' initializer_list comma_opt '}' 782 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME805 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } 783 806 ; 784 807 … … 850 873 | exception_statement 851 874 | enable_disable_statement 852 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME875 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } 853 876 | asm_statement 854 877 ; … … 917 940 { $$ = new StatementNode( build_if( $4, $6, $8 ) ); } 918 941 | SWITCH '(' comma_expression ')' case_clause 919 { $$ = new StatementNode( build_switch( $3, $5 ) ); }942 { $$ = new StatementNode( build_switch( true, $3, $5 ) ); } 920 943 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 921 944 { 922 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );945 StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) ); 923 946 // The semantics of the declaration list is changed to include associated initialization, which is performed 924 947 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound … … 929 952 } 930 953 | CHOOSE '(' comma_expression ')' case_clause // CFA 931 { $$ = new StatementNode( build_switch( $3, $5 ) ); }932 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA933 { 934 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );954 { $$ = new StatementNode( build_switch( false, $3, $5 ) ); } 955 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 956 { 957 StatementNode *sw = new StatementNode( build_switch( false, $3, $8 ) ); 935 958 $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 936 959 } … … 970 993 ; 971 994 995 //label_list_opt: 996 // // empty 997 // | identifier_or_type_name ':' 998 // | label_list_opt identifier_or_type_name ':' 999 // ; 1000 972 1001 case_label_list: // CFA 973 1002 case_label … … 990 1019 | switch_clause_list case_label_list statement_list_nodecl 991 1020 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); } 992 ;993 994 choose_clause_list_opt: // CFA995 // empty996 { $$ = nullptr; }997 | choose_clause_list998 ;999 1000 choose_clause_list: // CFA1001 case_label_list fall_through1002 { $$ = $1->append_last_case( $2 ); }1003 | case_label_list statement_list_nodecl fall_through_opt1004 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }1005 | choose_clause_list case_label_list fall_through1006 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }1007 | choose_clause_list case_label_list statement_list_nodecl fall_through_opt1008 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }1009 ;1010 1011 fall_through_opt: // CFA1012 // empty1013 { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); } // insert implicit break1014 | fall_through1015 ;1016 1017 fall_through_name: // CFA1018 FALLTHRU1019 | FALLTHROUGH1020 ;1021 1022 fall_through: // CFA1023 fall_through_name1024 { $$ = nullptr; }1025 | fall_through_name ';'1026 { $$ = nullptr; }1027 1021 ; 1028 1022 … … 1050 1044 // whereas normal operator precedence yields goto (*i)+3; 1051 1045 { $$ = new StatementNode( build_computedgoto( $3 ) ); } 1046 // A semantic check is required to ensure fallthru appears only in the body of a choose statement. 1047 | fall_through_name ';' // CFA 1048 { $$ = new StatementNode( build_branch( BranchStmt::FallThrough ) ); } 1049 | fall_through_name identifier_or_type_name ';' // CFA 1050 { $$ = new StatementNode( build_branch( $2, BranchStmt::FallThrough ) ); } 1051 | fall_through_name DEFAULT ';' // CFA 1052 { $$ = new StatementNode( build_branch( BranchStmt::FallThroughDefault ) ); } 1052 1053 | CONTINUE ';' 1053 1054 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. … … 1067 1068 { $$ = new StatementNode( build_return( $2 ) ); } 1068 1069 | RETURN '{' initializer_list comma_opt '}' 1069 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME1070 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } 1070 1071 | THROW assignment_expression_opt ';' // handles rethrow 1071 1072 { $$ = new StatementNode( build_throw( $2 ) ); } … … 1076 1077 ; 1077 1078 1079 fall_through_name: // CFA 1080 FALLTHRU 1081 | FALLTHROUGH 1082 ; 1083 1078 1084 with_statement: 1079 1085 WITH '(' tuple_expression_list ')' statement … … 1086 1092 mutex_statement: 1087 1093 MUTEX '(' argument_expression_list ')' statement 1088 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME1094 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } 1089 1095 ; 1090 1096 1091 1097 when_clause: 1092 WHEN '(' comma_expression ')' 1093 { $$ = $3; } 1098 WHEN '(' comma_expression ')' { $$ = $3; } 1094 1099 ; 1095 1100 … … 1115 1120 1116 1121 timeout: 1117 TIMEOUT '(' comma_expression ')' 1118 { $$ = $3; } 1122 TIMEOUT '(' comma_expression ')' { $$ = $3; } 1119 1123 ; 1120 1124 … … 1159 1163 //empty 1160 1164 { $$ = nullptr; } 1161 | ';' conditional_expression 1162 { $$ = $2; } 1165 | ';' conditional_expression { $$ = $2; } 1163 1166 ; 1164 1167 1165 1168 handler_key: 1166 CATCH 1167 { $$ = CatchStmt::Terminate; } 1168 | CATCHRESUME 1169 { $$ = CatchStmt::Resume; } 1169 CATCH { $$ = CatchStmt::Terminate; } 1170 | CATCHRESUME { $$ = CatchStmt::Resume; } 1170 1171 ; 1171 1172 1172 1173 finally_clause: 1173 FINALLY compound_statement 1174 { 1175 $$ = new StatementNode( build_finally( $2 ) ); 1176 } 1174 FINALLY compound_statement { $$ = new StatementNode( build_finally( $2 ) ); } 1177 1175 ; 1178 1176 … … 1316 1314 static_assert: 1317 1315 STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11 1318 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME1316 { $$ = DeclarationNode::newStaticAssert( $3, $5 ); } 1319 1317 1320 1318 // C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function … … 1710 1708 | LONG 1711 1709 { $$ = DeclarationNode::newLength( DeclarationNode::Long ); } 1712 | ZERO_T1713 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }1714 | ONE_T1715 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }1716 1710 | VALIST // GCC, __builtin_va_list 1717 1711 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } … … 1733 1727 basic_type_specifier: 1734 1728 direct_type 1729 // Cannot have type modifiers, e.g., short, long, etc. 1735 1730 | type_qualifier_list_opt indirect_type type_qualifier_list_opt 1736 1731 { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); } … … 1738 1733 1739 1734 direct_type: 1740 // A semantic check is necessary for conflicting type qualifiers.1741 1735 basic_type_name 1742 1736 | type_qualifier_list basic_type_name … … 1757 1751 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type(a+b) y; 1758 1752 { $$ = DeclarationNode::newAttr( $1, $3 ); } 1753 | ZERO_T // CFA 1754 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1755 | ONE_T // CFA 1756 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1759 1757 ; 1760 1758 … … 2413 2411 $$ = $2; 2414 2412 } 2415 | forall'{' external_definition_list '}' // CFA, namespace2413 | type_qualifier_list '{' external_definition_list '}' // CFA, namespace 2416 2414 ; 2417 2415
Note: See TracChangeset
for help on using the changeset viewer.