Changeset 1cdfa82 for src/Parser


Ignore:
Timestamp:
Apr 25, 2018, 4:55:53 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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.
Message:

Merge remote-tracking branch 'origin/master' into with_gc

Location:
src/Parser
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:37:17 2018
    13 // Update Count     : 1033
     12// Last Modified On : Fri Apr 20 22:37:20 2018
     13// Update Count     : 1063
    1414//
    1515
     
    4747const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };
    4848const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" };
    49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "NoBuiltinTypeNames" };
     49const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "zero_t", "one_t", "NoBuiltinTypeNames" };
    5050
    5151UniqueName DeclarationNode::anonymous( "__anonymous" );
     
    7171        attr.expr = nullptr;
    7272        attr.type = nullptr;
     73
     74        assert.condition = nullptr;
     75        assert.message = nullptr;
    7376}
    7477
     
    8891        // asmName, no delete, passed to next stage
    8992        delete initializer;
     93
     94        delete assert.condition;
     95        delete assert.message;
    9096}
    9197
     
    117123        newnode->attr.expr = maybeClone( attr.expr );
    118124        newnode->attr.type = maybeClone( attr.type );
     125
     126        newnode->assert.condition = maybeClone( assert.condition );
     127        newnode->assert.message = maybeClone( assert.message );
    119128        return newnode;
    120129} // DeclarationNode::clone
     
    434443        return newnode;
    435444}
     445
     446DeclarationNode * 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
    436453
    437454void appendError( string & dst, const string & src ) {
     
    544561
    545562        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
    546567        addQualifiersToType( q->type, type );
    547568
     
    907928                                delete newType->aggInst.aggregate->enumeration.constants;
    908929                                newType->aggInst.aggregate->enumeration.constants = nullptr;
     930                                newType->aggInst.aggregate->enumeration.body = false;
    909931                        } else {
    910932                                assert( newType->aggInst.aggregate->kind == TypeData::Aggregate );
    911933                                delete newType->aggInst.aggregate->aggregate.fields;
    912934                                newType->aggInst.aggregate->aggregate.fields = nullptr;
     935                                newType->aggInst.aggregate->aggregate.body = false;
    913936                        } // if
    914937                        // don't hoist twice
     
    10511074        } // if
    10521075
     1076        if ( assert.condition ) {
     1077                return new StaticAssertDecl( maybeBuild< Expression >( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) );
     1078        }
     1079
    10531080        // SUE's cannot have function specifiers, either
    10541081        //
  • src/Parser/ExpressionNode.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  3 18:22:33 2018
    13 // Update Count     : 796
     12// Last Modified On : Thu Mar 22 11:57:39 2018
     13// Update Count     : 801
    1414//
    1515
     
    9494} // checkLNInt
    9595
    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 units
    100                 str.erase( posn );                                                              // remove units
    101         } // if
    102 } // sepNumeric
    103 
    10496Expression * build_constantInteger( string & str ) {
    10597        static const BasicType::Kind kind[2][6] = {
     
    108100                { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, },
    109101        };
    110 
    111         string units;
    112         sepNumeric( str, units );                                                       // separate constant from units
    113102
    114103        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
     
    222211        if ( Unsigned && size < 2 ) {                                           // hh or h, less than int ?
    223212                // 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 );
    225214        } else if ( lnth != -1 ) {                                                      // explicit length ?
    226215                if ( lnth == 5 ) {                                                              // int128 ?
    227216                        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 );
    229218                } 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 );
    231220                } // if
    232221        } // if
    233222  CLEANUP:
    234         if ( units.length() != 0 ) {
    235                 ret = new UntypedExpr( new NameExpr( units ), { ret } );
    236         } // if
    237223
    238224        delete &str;                                                                            // created by lex
     
    268254        };
    269255
    270         string units;
    271         sepNumeric( str, units );                                                       // separate constant from units
    272 
    273256        bool complx = false;                                                            // real, complex
    274257        int size = 1;                                                                           // 0 => float, 1 => double, 2 => long double
     
    302285        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) );
    303286        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 );
    308288        } // if
    309289
     
    427407        Type * targetType = maybeMoveBuildType( decl_node );
    428408        if ( dynamic_cast< VoidType * >( targetType ) ) {
    429                 return new CastExpr( maybeMoveBuild< Expression >(expr_node) );
     409                return new CastExpr( maybeMoveBuild< Expression >(expr_node), false );
    430410        } else {
    431                 return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );
     411                return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType, false );
    432412        } // if
    433413} // build_cast
     414
     415Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) {
     416        return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target );
     417}
    434418
    435419Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
  • src/Parser/ParseNode.h

    r2efe4b8 r1cdfa82  
    179179
    180180Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
     181Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node );
    181182Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node );
    182183Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member );
     
    246247        static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    247248        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
     249        static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message );
    248250
    249251        DeclarationNode();
     
    313315        Attr_t attr;
    314316
     317        struct StaticAssert_t {
     318                ExpressionNode * condition;
     319                Expression * message;
     320        };
     321        StaticAssert_t assert;
     322
    315323        BuiltinType builtin;
    316324
     
    392400
    393401Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    394 Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt );
     402Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    395403Statement * build_case( ExpressionNode * ctl );
    396404Statement * build_default();
  • src/Parser/StatementNode.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat May 16 14:59:41 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Sep  1 23:25:23 2017
    13 // Update Count     : 346
     12// Last Modified On : Thu Mar  8 14:31:32 2018
     13// Update Count     : 348
    1414//
    1515
     
    115115}
    116116
    117 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {
     117Statement *build_switch( bool isSwitch, ExpressionNode *ctl, StatementNode *stmt ) {
    118118        std::list< Statement * > branches;
    119119        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
    120129        // branches.size() == 0 for switch (...) {}, i.e., no declaration or statements
    121130        return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
  • src/Parser/TypeData.cc

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 15:49:00 2018
    13 // Update Count     : 597
     12// Last Modified On : Tue Apr 17 23:00:52 2018
     13// Update Count     : 602
    1414//
    1515
     
    395395                break;
    396396          case Builtin:
    397                 os << "gcc builtin type";
     397                os << DeclarationNode::builtinTypeNames[builtintype];
    398398                break;
    399399          default:
     
    490490        switch ( td->kind ) {
    491491          case TypeData::Aggregate:
    492                 if ( ! toplevel && td->aggregate.fields ) {
     492                if ( ! toplevel && td->aggregate.body ) {
    493493                        ret = td->clone();
    494494                } // if
    495495                break;
    496496          case TypeData::Enum:
    497                 if ( ! toplevel && td->enumeration.constants ) {
     497                if ( ! toplevel && td->enumeration.body ) {
    498498                        ret = td->clone();
    499499                } // if
  • src/Parser/lex.ll

    r2efe4b8 r1cdfa82  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Sat Mar  3 18:38:16 2018
    13  * Update Count     : 640
     12 * Last Modified On : Fri Apr  6 15:16:15 2018
     13 * Update Count     : 670
    1414 */
    1515
     
    5454
    5555void 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?)
    5757        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
    6759                if ( yytext[i] != '_' ) {
    6860                        yytext[yyleng] = yytext[i];
     
    7163        } // for
    7264        yytext[yyleng] = '\0';
    73 }
     65} // rm_underscore
    7466
    7567// Stop warning due to incorrectly generated flex code.
     
    9082attr_identifier "@"{identifier}
    9183
    92 user_suffix_opt ("`"{identifier})?
    93 
    9484                                // numeric constants, CFA: '_' in constant
    9585hex_quad {hex}("_"?{hex}){3}
    9686size_opt (8|16|32|64|128)?
    9787length ("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}
     88integer_suffix_opt ("_"?(([uU]({length}?[iI]?)|([iI]{length}))|([iI]({length}?[uU]?)|([uU]{length}))|({length}([iI]?[uU]?)|([uU][iI]))|[zZ]))?
    9989
    10090octal_digits ({octal})|({octal}({octal}|"_")*{octal})
     
    118108floating_length ([fFdDlL]|[lL]{floating_size})
    119109floating_suffix ({floating_length}?[iI]?)|([iI]{floating_length})
    120 floating_suffix_opt ("_"?({floating_suffix}|"DL"))?{user_suffix_opt}
     110floating_suffix_opt ("_"?({floating_suffix}|"DL"))?
    121111decimal_digits ({decimal})|({decimal}({decimal}|"_")*{decimal})
    122112floating_decimal {decimal_digits}"."{exponent}?{floating_suffix_opt}
     
    125115
    126116binary_exponent "_"?[pP]"_"?[+-]?{decimal_digits}
    127 hex_floating_suffix_opt ("_"?({floating_suffix}))?{user_suffix_opt}
     117hex_floating_suffix_opt ("_"?({floating_suffix}))?
    128118hex_floating_fraction ({hex_digits}?"."{hex_digits})|({hex_digits}".")
    129119hex_floating_constant {hex_prefix}(({hex_floating_fraction}{binary_exponent})|({hex_digits}{binary_exponent})){hex_floating_suffix_opt}
     
    208198__asm                   { KEYWORD_RETURN(ASM); }                                // GCC
    209199__asm__                 { KEYWORD_RETURN(ASM); }                                // GCC
    210 _At                             { KEYWORD_RETURN(AT); }                                 // CFA
    211200_Atomic                 { KEYWORD_RETURN(ATOMIC); }                             // C11
    212201__attribute             { KEYWORD_RETURN(ATTRIBUTE); }                  // GCC
     
    239228exception               { KEYWORD_RETURN(EXCEPTION); }                  // CFA
    240229extern                  { KEYWORD_RETURN(EXTERN); }
     230fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    241231fallthru                { KEYWORD_RETURN(FALLTHRU); }                   // CFA
    242 fallthrough             { KEYWORD_RETURN(FALLTHROUGH); }                // CFA
    243232finally                 { KEYWORD_RETURN(FINALLY); }                    // CFA
    244233float                   { KEYWORD_RETURN(FLOAT); }
     
    270259__builtin_offsetof { KEYWORD_RETURN(OFFSETOF); }                // GCC
    271260one_t                   { NUMERIC_RETURN(ONE_T); }                              // CFA
     261or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    272262otype                   { KEYWORD_RETURN(OTYPE); }                              // CFA
    273263register                { KEYWORD_RETURN(REGISTER); }
     
    306296__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    307297waitfor                 { KEYWORD_RETURN(WAITFOR); }
    308 or                              { QKEYWORD_RETURN(WOR); }                               // CFA
    309298when                    { KEYWORD_RETURN(WHEN); }
    310299while                   { KEYWORD_RETURN(WHILE); }
     
    314303                                /* identifier */
    315304{identifier}    { IDENTIFIER_RETURN(); }
     305"`"{identifier}"`" {                                                                    // CFA
     306        yytext[yyleng - 1] = '\0'; yytext += 1;                         // SKULLDUGGERY: remove backquotes (ok to shorten?)
     307        IDENTIFIER_RETURN();
     308}
    316309{attr_identifier} { ATTRIBUTE_RETURN(); }
    317 "`"                             { BEGIN BKQUOTE; }
    318 <BKQUOTE>{identifier} { IDENTIFIER_RETURN(); }
    319 <BKQUOTE>"`"    { BEGIN 0; }
    320310
    321311                                /* numeric constants */
     
    332322({cwide_prefix}[_]?)?['] { BEGIN QUOTE; rm_underscore(); strtext = new string( yytext, yyleng ); }
    333323<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); }
    335325                                /* ' stop editor highlighting */
    336326
     
    338328({swide_prefix}[_]?)?["] { BEGIN STRING; rm_underscore(); strtext = new string( yytext, yyleng ); }
    339329<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); }
    341331                                /* " stop editor highlighting */
    342332
     
    348338                                /* punctuation */
    349339"@"                             { ASCIIOP_RETURN(); }
     340"`"                             { ASCIIOP_RETURN(); }
    350341"["                             { ASCIIOP_RETURN(); }
    351342"]"                             { ASCIIOP_RETURN(); }
     
    412403"?"({op_unary_pre_post}|"()"|"[?]"|"{}") { IDENTIFIER_RETURN(); }
    413404"^?{}"                  { IDENTIFIER_RETURN(); }
    414 "?`"{identifier} { IDENTIFIER_RETURN(); }                               // unit operator
     405"?`"{identifier} { IDENTIFIER_RETURN(); }                               // postfix operator
    415406"?"{op_binary_over}"?"  { IDENTIFIER_RETURN(); }                // binary
    416407        /*
  • src/Parser/parser.yy

    r2efe4b8 r1cdfa82  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 17:48:54 2018
    13 // Update Count     : 3028
     12// Last Modified On : Tue Apr 17 17:10:30 2018
     13// Update Count     : 3144
    1414//
    1515
     
    126126        } // if
    127127} // rebindForall
     128
     129NameExpr * 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
    128134
    129135bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
     
    254260%type<sn> statement_decl                                statement_decl_list                     statement_list_nodecl
    255261%type<sn> selection_statement
    256 %type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
     262%type<sn> switch_clause_list_opt                switch_clause_list
    257263%type<en> case_value
    258264%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    259 %type<sn> fall_through                                  fall_through_opt
    260265%type<sn> iteration_statement                   jump_statement
    261266%type<sn> expression_statement                  asm_statement
     
    386391%precedence '('
    387392
    388 %locations                      // support location tracking for error messages
     393%locations                                                                                              // support location tracking for error messages
    389394
    390395%start translation_unit                                                                 // parse-tree root
     
    481486        | '(' compound_statement ')'                                            // GCC, lambda expression
    482487                { $$ = 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 ) ); }
    483498        | type_name '.' no_attr_identifier                                      // CFA, nested type
    484                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     499                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    485500        | type_name '.' '[' push field_list pop ']'                     // CFA, nested type / tuple field selector
    486                 { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; } // FIX ME
     501                { SemanticError( yylloc, "Qualified names are currently unimplemented." ); $$ = nullptr; }
    487502        | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11
    488                 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } // FIX ME
     503                { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; }
    489504        ;
    490505
     
    535550        | '(' type_no_function ')' '{' initializer_list comma_opt '}' // C99, compound-literal
    536551                { $$ = 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 ) ) ); }
    537554        | '^' primary_expression '{' argument_expression_list '}' // CFA
    538555                {
     
    670687        | '(' type_no_function ')' cast_expression
    671688                { $$ = 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 ) ); }
    672695                // VIRTUAL cannot be opt because of look ahead issues
    673         | '(' VIRTUAL ')' cast_expression
     696        | '(' VIRTUAL ')' cast_expression                                       // CFA
    674697                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
    675         | '(' VIRTUAL type_no_function ')' cast_expression
     698        | '(' VIRTUAL type_no_function ')' cast_expression      // CFA
    676699                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $5 ), maybeMoveBuildType( $3 ) ) ); }
    677700//      | '(' type_no_function ')' tuple
     
    765788        | logical_OR_expression '?' comma_expression ':' conditional_expression
    766789                { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); }
    767                 // FIX ME: this hack computes $1 twice
     790                // FIX ME: computes $1 twice
    768791        | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand
    769792                { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); }
     
    780803                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    781804        | unary_expression '=' '{' initializer_list comma_opt '}'
    782                 { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; } // FIX ME
     805                { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; }
    783806        ;
    784807
     
    850873        | exception_statement
    851874        | enable_disable_statement
    852                 { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     875                { SemanticError( yylloc, "enable/disable statement is currently unimplemented." ); $$ = nullptr; }
    853876        | asm_statement
    854877        ;
     
    917940                { $$ = new StatementNode( build_if( $4, $6, $8 ) ); }
    918941        | SWITCH '(' comma_expression ')' case_clause
    919                 { $$ = new StatementNode( build_switch( $3, $5 ) ); }
     942                { $$ = new StatementNode( build_switch( true, $3, $5 ) ); }
    920943        | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA
    921944                {
    922                         StatementNode *sw = new StatementNode( build_switch( $3, $8 ) );
     945                        StatementNode *sw = new StatementNode( build_switch( true, $3, $8 ) );
    923946                        // The semantics of the declaration list is changed to include associated initialization, which is performed
    924947                        // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound
     
    929952                }
    930953        | 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 '}' // CFA
    933                 {
    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 ) );
    935958                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    936959                }
     
    970993        ;
    971994
     995//label_list_opt:
     996//      // empty
     997//      | identifier_or_type_name ':'
     998//      | label_list_opt identifier_or_type_name ':'
     999//      ;
     1000
    9721001case_label_list:                                                                                // CFA
    9731002        case_label
     
    9901019        | switch_clause_list case_label_list statement_list_nodecl
    9911020                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
    992         ;
    993 
    994 choose_clause_list_opt:                                                                 // CFA
    995         // empty
    996                 { $$ = nullptr; }
    997         | choose_clause_list
    998         ;
    999 
    1000 choose_clause_list:                                                                             // CFA
    1001         case_label_list fall_through
    1002                 { $$ = $1->append_last_case( $2 ); }
    1003         | case_label_list statement_list_nodecl fall_through_opt
    1004                 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
    1005         | choose_clause_list case_label_list fall_through
    1006                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
    1007         | choose_clause_list case_label_list statement_list_nodecl fall_through_opt
    1008                 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }
    1009         ;
    1010 
    1011 fall_through_opt:                                                                               // CFA
    1012         // empty
    1013                 { $$ = new StatementNode( build_branch( BranchStmt::Break ) ); } // insert implicit break
    1014         | fall_through
    1015         ;
    1016 
    1017 fall_through_name:                                                                              // CFA
    1018         FALLTHRU
    1019         | FALLTHROUGH
    1020         ;
    1021 
    1022 fall_through:                                                                                   // CFA
    1023         fall_through_name
    1024                 { $$ = nullptr; }
    1025         | fall_through_name ';'
    1026                 { $$ = nullptr; }
    10271021        ;
    10281022
     
    10501044                // whereas normal operator precedence yields goto (*i)+3;
    10511045                { $$ = 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 ) ); }
    10521053        | CONTINUE ';'
    10531054                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
     
    10671068                { $$ = new StatementNode( build_return( $2 ) ); }
    10681069        | RETURN '{' initializer_list comma_opt '}'
    1069                 { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1070                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
    10701071        | THROW assignment_expression_opt ';'                           // handles rethrow
    10711072                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    10761077        ;
    10771078
     1079fall_through_name:                                                                              // CFA
     1080        FALLTHRU
     1081        | FALLTHROUGH
     1082        ;
     1083
    10781084with_statement:
    10791085        WITH '(' tuple_expression_list ')' statement
     
    10861092mutex_statement:
    10871093        MUTEX '(' argument_expression_list ')' statement
    1088                 { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1094                { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; }
    10891095        ;
    10901096
    10911097when_clause:
    1092         WHEN '(' comma_expression ')'
    1093                 { $$ = $3; }
     1098        WHEN '(' comma_expression ')'                           { $$ = $3; }
    10941099        ;
    10951100
     
    11151120
    11161121timeout:
    1117         TIMEOUT '(' comma_expression ')'
    1118                 { $$ = $3; }
     1122        TIMEOUT '(' comma_expression ')'                        { $$ = $3; }
    11191123        ;
    11201124
     
    11591163        //empty
    11601164                { $$ = nullptr; }
    1161         | ';' conditional_expression
    1162                 { $$ = $2; }
     1165        | ';' conditional_expression                            { $$ = $2; }
    11631166        ;
    11641167
    11651168handler_key:
    1166         CATCH
    1167                 { $$ = CatchStmt::Terminate; }
    1168         | CATCHRESUME
    1169                 { $$ = CatchStmt::Resume; }
     1169        CATCH                                                                           { $$ = CatchStmt::Terminate; }
     1170        | CATCHRESUME                                                           { $$ = CatchStmt::Resume; }
    11701171        ;
    11711172
    11721173finally_clause:
    1173         FINALLY compound_statement
    1174                 {
    1175                         $$ = new StatementNode( build_finally( $2 ) );
    1176                 }
     1174        FINALLY compound_statement                                      { $$ = new StatementNode( build_finally( $2 ) ); }
    11771175        ;
    11781176
     
    13161314static_assert:
    13171315        STATICASSERT '(' constant_expression ',' string_literal ')' ';' // C11
    1318                 { SemanticError( yylloc, "Static assert is currently unimplemented." ); $$ = nullptr; } // FIX ME
     1316                { $$ = DeclarationNode::newStaticAssert( $3, $5 ); }
    13191317
    13201318// C declaration syntax is notoriously confusing and error prone. Cforall provides its own type, variable and function
     
    17101708        | LONG
    17111709                { $$ = DeclarationNode::newLength( DeclarationNode::Long ); }
    1712         | ZERO_T
    1713                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    1714         | ONE_T
    1715                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17161710        | VALIST                                                                                        // GCC, __builtin_va_list
    17171711                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     
    17331727basic_type_specifier:
    17341728        direct_type
     1729                // Cannot have type modifiers, e.g., short, long, etc.
    17351730        | type_qualifier_list_opt indirect_type type_qualifier_list_opt
    17361731                { $$ = $2->addQualifiers( $1 )->addQualifiers( $3 ); }
     
    17381733
    17391734direct_type:
    1740                 // A semantic check is necessary for conflicting type qualifiers.
    17411735        basic_type_name
    17421736        | type_qualifier_list basic_type_name
     
    17571751        | ATTR_TYPEGENname '(' comma_expression ')'                     // CFA: e.g., @type(a+b) y;
    17581752                { $$ = DeclarationNode::newAttr( $1, $3 ); }
     1753        | ZERO_T                                                                                        // CFA
     1754                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     1755        | ONE_T                                                                                         // CFA
     1756                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    17591757        ;
    17601758
     
    24132411                        $$ = $2;
    24142412                }
    2415         | forall '{' external_definition_list '}'                       // CFA, namespace
     2413        | type_qualifier_list '{' external_definition_list '}'                  // CFA, namespace
    24162414        ;
    24172415
Note: See TracChangeset for help on using the changeset viewer.