Changeset 32cab5b for src/Parser


Ignore:
Timestamp:
Apr 17, 2018, 12:01:09 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
3265399
Parents:
b2fe1c9 (diff), 81bb114 (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 branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Parser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rb2fe1c9 r32cab5b  
    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 ) {
     
    10521069        } // if
    10531070
     1071        if ( assert.condition ) {
     1072                return new StaticAssertDecl( maybeBuild< Expression >( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) );
     1073        }
     1074
    10541075        // SUE's cannot have function specifiers, either
    10551076        //
  • src/Parser/ExpressionNode.cc

    rb2fe1c9 r32cab5b  
    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
     
    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
     
    303286        if ( lnth != -1 ) {                                                                     // explicit length ?
    304287                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 } );
    308288        } // if
    309289
  • src/Parser/ParseNode.h

    rb2fe1c9 r32cab5b  
    246246        static DeclarationNode * newAttribute( std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    247247        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
     248        static DeclarationNode * newStaticAssert( ExpressionNode * condition, Expression * message );
    248249
    249250        DeclarationNode();
     
    313314        Attr_t attr;
    314315
     316        struct StaticAssert_t {
     317                ExpressionNode * condition;
     318                Expression * message;
     319        };
     320        StaticAssert_t assert;
     321
    315322        BuiltinType builtin;
    316323
     
    392399
    393400Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );
    394 Statement * build_switch( ExpressionNode * ctl, StatementNode * stmt );
     401Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );
    395402Statement * build_case( ExpressionNode * ctl );
    396403Statement * build_default();
  • src/Parser/StatementNode.cc

    rb2fe1c9 r32cab5b  
    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
     
    116116}
    117117
    118 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {
     118Statement *build_switch( bool isSwitch, ExpressionNode *ctl, StatementNode *stmt ) {
    119119        std::list< Statement * > branches;
    120120        buildMoveList< Statement, StatementNode >( stmt, branches );
     121        if ( ! isSwitch ) {                                                                             // choose statement
     122                for ( Statement * stmt : branches ) {
     123                        CaseStmt * caseStmt = strict_dynamic_cast< CaseStmt * >( stmt );
     124                        if ( ! caseStmt->stmts.empty() ) {                      // code after "case" => end of case list
     125                                CompoundStmt * block = strict_dynamic_cast< CompoundStmt * >( caseStmt->stmts.front() );
     126                                block->kids.push_back( new BranchStmt( "", BranchStmt::Break ) );
     127                        } // if
     128                } // for
     129        } // if
    121130        // branches.size() == 0 for switch (...) {}, i.e., no declaration or statements
    122131        return new SwitchStmt( maybeMoveBuild< Expression >(ctl), branches );
  • src/Parser/lex.ll

    rb2fe1c9 r32cab5b  
    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

    rb2fe1c9 r32cab5b  
    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 : Wed Mar 28 17:52:24 2018
     13// Update Count     : 3130
    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
     
    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                { SemanticError( yylloc, "coroutine cast is currently unimplemented." ); $$ = nullptr; }
     691        | '(' THREAD '&' ')' cast_expression                            // CFA
     692                { SemanticError( yylloc, "monitor cast is currently unimplemented." ); $$ = nullptr; }
     693        | '(' MONITOR '&' ')' cast_expression                           // CFA
     694                { SemanticError( yylloc, "thread cast is currently unimplemented." ); $$ = nullptr; }
    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
     
    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.