Ignore:
Timestamp:
Feb 23, 2022, 11:24:34 AM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
08ed947
Parents:
f5a51db (diff), 3a038fa (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rf5a51db rcc7bbe6  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb  1 11:06:13 2022
    13 // Update Count     : 5167
     12// Last Modified On : Sat Feb 19 09:47:20 2022
     13// Update Count     : 5218
    1414//
    1515
     
    10521052        identifier_or_type_name ':' attribute_list_opt statement
    10531053                { $$ = $4->add_label( $1, $3 ); }
     1054        | identifier_or_type_name ':' attribute_list_opt error
     1055                { SemanticError( yylloc, "previous label must be associated with a statement (where a declaration is not a statement). Move the label or terminate with a semi-colon." ); $$ = nullptr; }
    10541056        ;
    10551057
     
    10861088        | statement_list_nodecl statement
    10871089                { assert( $1 ); $1->set_last( $2 ); $$ = $1; }
     1090        | statement_list_nodecl error
     1091                { SemanticError( yylloc, "declarations only allowed at the start of the switch body, i.e., after the '{'." ); $$ = nullptr; }
    10881092        ;
    10891093
     
    10931097        | MUTEX '(' ')' comma_expression ';'
    10941098                { $$ = new StatementNode( build_mutex( nullptr, new StatementNode( build_expr( $4 ) ) ) ); }
    1095                 // { SemanticError( yylloc, "Mutex expression is currently unimplemented." ); $$ = nullptr; }
    10961099        ;
    10971100
     
    11131116                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    11141117                }
     1118        | SWITCH '(' comma_expression ')' '{' error '}'         // CFA
     1119                { SemanticError( yylloc, "only declarations can appear before the list of case clauses." ); $$ = nullptr; }
    11151120        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    11161121                { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }
     
    11201125                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    11211126                }
     1127        | CHOOSE '(' comma_expression ')' '{' error '}'         // CFA
     1128                { SemanticError( yylloc, "only declarations can appear before the list of case clauses." ); $$ = nullptr; }
    11221129        ;
    11231130
     
    11581165
    11591166case_label:                                                                                             // CFA
    1160         CASE case_value_list ':'                                        { $$ = $2; }
     1167        CASE error
     1168                { SemanticError( yylloc, "missing case list after case." ); $$ = nullptr; }
     1169        | CASE case_value_list ':'                                      { $$ = $2; }
     1170        | CASE case_value_list error
     1171                { SemanticError( yylloc, "missing colon after case list." ); $$ = nullptr; }
    11611172        | DEFAULT ':'                                                           { $$ = new StatementNode( build_default() ); }
    11621173                // A semantic check is required to ensure only one default clause per switch/choose statement.
    1163         ;
    1164 
    1165 //label_list_opt:
    1166 //      // empty
    1167 //      | identifier_or_type_name ':'
    1168 //      | label_list_opt identifier_or_type_name ':'
    1169 //      ;
     1174        | DEFAULT error
     1175                { SemanticError( yylloc, "missing colon after default." ); $$ = nullptr; }
     1176        ;
    11701177
    11711178case_label_list:                                                                                // CFA
     
    11971204                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
    11981205        | WHILE '(' conditional_declaration ')' statement ELSE statement // CFA
    1199                 // { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    12001206                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ), $7 ) ); }
    12011207        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
     
    12041210                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
    12051211        | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA
    1206                 // { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    12071212                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ), $8 ) ); }
    12081213        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
     
    12111216                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
    12121217        | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA
    1213                 // { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    12141218                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ), $7 ) ); }
    12151219        ;
     
    27292733        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    27302734                { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); }
     2735        | EXTERN STRINGliteral
     2736                {
     2737                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     2738                        linkage = LinkageSpec::update( yylloc, linkage, $2 );
     2739                }
     2740          up external_definition down
     2741                {
     2742                        linkage = linkageStack.top();
     2743                        linkageStack.pop();
     2744                        $$ = $5;
     2745                }
    27312746        | EXTERN STRINGliteral                                                          // C++-style linkage specifier
    27322747                {
Note: See TracChangeset for help on using the changeset viewer.