Ignore:
Timestamp:
Apr 10, 2022, 2:53:18 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
d8e2a09
Parents:
4559b34 (diff), 6256891 (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:

Resolve conflict

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r4559b34 r92538ab  
    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 : Mon Mar 14 16:35:29 2022
     13// Update Count     : 5276
    1414//
    1515
     
    610610        // | RESUME '(' comma_expression ')' compound_statement
    611611        //      { SemanticError( yylloc, "Resume expression is currently unimplemented." ); $$ = nullptr; }
     612        | IDENTIFIER IDENTIFIER                                                         // syntax error
     613                {
     614                        SemanticError( yylloc, ::toString( "Adjacent identifiers are not meaningful in an expression. "
     615                                                                                           "Possible problem is identifier \"", *$1.str,
     616                                                                                           "\" is a misspelled typename or an incorrectly specified type name, "
     617                                                                                           "e.g., missing generic parameter or missing struct/union/enum before typename." ) );
     618                        $$ = nullptr;
     619                }
     620        | IDENTIFIER direct_type                                                        // syntax error
     621                {
     622                        SemanticError( yylloc, ::toString( "Identifier \"", *$1.str, "\" cannot appear before a type. "
     623                                                                                           "Possible problem is misspelled storage or CV qualifier." ) );
     624                        $$ = nullptr;
     625                }
    612626        ;
    613627
     
    638652                        // Historic, transitional: Disallow commas in subscripts.
    639653                        // Switching to this behaviour may help check if a C compatibilty case uses comma-exprs in subscripts.
    640                 // { SemanticError( yylloc, "New array subscript is currently unimplemented." ); $$ = nullptr; }
    641654                        // Current: Commas in subscripts make tuples.
    642655                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $5 ) ) )) ) ); }
     
    647660                // equivalent to the old x[i,j].
    648661                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }
     662        | constant '[' assignment_expression ']'                        // 3[a], 'a'[a], 3.5[a]
     663                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }
     664        | string_literal '[' assignment_expression ']'          // "abc"[3], 3["abc"]
     665                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, new ExpressionNode( $1 ), $3 ) ); }
    649666        | postfix_expression '{' argument_expression_list_opt '}' // CFA, constructor call
    650667                {
     
    10521069        identifier_or_type_name ':' attribute_list_opt statement
    10531070                { $$ = $4->add_label( $1, $3 ); }
     1071        | identifier_or_type_name ':' attribute_list_opt error // syntax error
     1072                {
     1073                        SemanticError( yylloc, ::toString( "Label \"", *$1.str, "\" must be associated with a statement, "
     1074                                                                                           "where a declaration, case, or default is not a statement. "
     1075                                                                                           "Move the label or terminate with a semi-colon." ) );
     1076                        $$ = nullptr;
     1077                }
    10541078        ;
    10551079
     
    10861110        | statement_list_nodecl statement
    10871111                { assert( $1 ); $1->set_last( $2 ); $$ = $1; }
     1112        | statement_list_nodecl error                                           // syntax error
     1113                { SemanticError( yylloc, "Declarations only allowed at the start of the switch body, i.e., after the '{'." ); $$ = nullptr; }
    10881114        ;
    10891115
     
    10931119        | MUTEX '(' ')' comma_expression ';'
    10941120                { $$ = new StatementNode( build_mutex( nullptr, new StatementNode( build_expr( $4 ) ) ) ); }
    1095                 // { SemanticError( yylloc, "Mutex expression is currently unimplemented." ); $$ = nullptr; }
    10961121        ;
    10971122
     
    11131138                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    11141139                }
     1140        | SWITCH '(' comma_expression ')' '{' error '}'         // CFA, syntax error
     1141                { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; }
    11151142        | CHOOSE '(' comma_expression ')' case_clause           // CFA
    11161143                { $$ = new StatementNode( build_switch( false, $3, $5 ) ); }
     
    11201147                        $$ = $7 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw;
    11211148                }
     1149        | CHOOSE '(' comma_expression ')' '{' error '}'         // CFA, syntax error
     1150                { SemanticError( yylloc, "Only declarations can appear before the list of case clauses." ); $$ = nullptr; }
    11221151        ;
    11231152
     
    11581187
    11591188case_label:                                                                                             // CFA
    1160         CASE case_value_list ':'                                        { $$ = $2; }
     1189        CASE error                                                                                      // syntax error
     1190                { SemanticError( yylloc, "Missing case list after case." ); $$ = nullptr; }
     1191        | CASE case_value_list ':'                                      { $$ = $2; }
     1192        | CASE case_value_list error                                            // syntax error
     1193                { SemanticError( yylloc, "Missing colon after case list." ); $$ = nullptr; }
    11611194        | DEFAULT ':'                                                           { $$ = new StatementNode( build_default() ); }
    11621195                // 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 //      ;
     1196        | DEFAULT error                                                                         //  syntax error
     1197                { SemanticError( yylloc, "Missing colon after default." ); $$ = nullptr; }
     1198        ;
    11701199
    11711200case_label_list:                                                                                // CFA
     
    11971226                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
    11981227        | WHILE '(' conditional_declaration ')' statement ELSE statement // CFA
    1199                 // { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    12001228                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ), $7 ) ); }
    12011229        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
     
    12041232                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
    12051233        | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA
    1206                 // { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    12071234                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ), $8 ) ); }
    12081235        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
     
    12111238                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
    12121239        | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA
    1213                 // { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    12141240                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ), $7 ) ); }
    12151241        ;
     
    14061432        | when_clause_opt ELSE statement
    14071433                { $$ = build_waitfor_timeout( nullptr, maybe_build_compound( $3 ), $1 ); }
    1408                 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
    1409         | when_clause_opt timeout statement WOR ELSE statement
     1434        // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
     1435        | when_clause_opt timeout statement WOR ELSE statement // syntax error
    14101436                { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }
    14111437        | when_clause_opt timeout statement WOR when_clause ELSE statement
     
    27352761        | ASM '(' string_literal ')' ';'                                        // GCC, global assembler statement
    27362762                { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); }
     2763        | EXTERN STRINGliteral
     2764                {
     2765                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
     2766                        linkage = LinkageSpec::update( yylloc, linkage, $2 );
     2767                }
     2768          up external_definition down
     2769                {
     2770                        linkage = linkageStack.top();
     2771                        linkageStack.pop();
     2772                        $$ = $5;
     2773                }
    27372774        | EXTERN STRINGliteral                                                          // C++-style linkage specifier
    27382775                {
Note: See TracChangeset for help on using the changeset viewer.