Ignore:
Timestamp:
Jan 7, 2021, 3:27:00 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2b4daf2, 64aeca0
Parents:
3c64c668 (diff), eef8dfb (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' into park_unpark

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r3c64c668 r58fe85a  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Feb 21 14:47:29 2020
    13 // Update Count     : 4468
     12// Last Modified On : Sat Oct 24 08:21:14 2020
     13// Update Count     : 4624
    1414//
    1515
     
    204204                        return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
    205205                } else {
    206                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
     206                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed." ); return nullptr;
    207207                } // if
    208208        } else {
    209                 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
     209                SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed." ); return nullptr;
    210210        } // if
    211211} // forCtrl
     
    278278%token OTYPE FTYPE DTYPE TTYPE TRAIT                                    // CFA
    279279%token SIZEOF OFFSETOF
    280 // %token SUSPEND RESUME                                                                        // CFA
     280// %token RESUME                                                                                        // CFA
     281%token SUSPEND                                                                                  // CFA
    281282%token ATTRIBUTE EXTENSION                                                              // GCC
    282283%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
     
    328329%type<en> conditional_expression                constant_expression                     assignment_expression           assignment_expression_opt
    329330%type<en> comma_expression                              comma_expression_opt
    330 %type<en> argument_expression_list              argument_expression                     default_initialize_opt
     331%type<en> argument_expression_list_opt  argument_expression                     default_initialize_opt
    331332%type<ifctl> if_control_expression
    332333%type<fctl> for_control_expression              for_control_expression_list
     
    369370%type<decl> assertion assertion_list assertion_list_opt
    370371
    371 %type<en>   bit_subrange_size_opt bit_subrange_size
     372%type<en> bit_subrange_size_opt bit_subrange_size
    372373
    373374%type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type indirect_type
     
    623624                // equivalent to the old x[i,j].
    624625                { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $3 ) ); }
    625         | postfix_expression '{' argument_expression_list '}' // CFA, constructor call
     626        | postfix_expression '{' argument_expression_list_opt '}' // CFA, constructor call
    626627                {
    627628                        Token fn;
     
    629630                        $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) );
    630631                }
    631         | postfix_expression '(' argument_expression_list ')'
     632        | postfix_expression '(' argument_expression_list_opt ')'
    632633                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    633634        | postfix_expression '`' identifier                                     // CFA, postfix call
     
    661662        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    662663                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    663         | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call
     664        | '^' primary_expression '{' argument_expression_list_opt '}' // CFA, destructor call
    664665                {
    665666                        Token fn;
     
    669670        ;
    670671
    671 argument_expression_list:
     672argument_expression_list_opt:
    672673        // empty
    673674                { $$ = nullptr; }
    674675        | argument_expression
    675         | argument_expression_list ',' argument_expression
     676        | argument_expression_list_opt ',' argument_expression
    676677                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    677678        ;
     
    792793        | '(' aggregate_control '&' ')' cast_expression         // CFA
    793794                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    794                 // VIRTUAL cannot be opt because of look ahead issues
    795795        | '(' VIRTUAL ')' cast_expression                                       // CFA
    796796                { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild< Expression >( $4 ), maybeMoveBuildType( nullptr ) ) ); }
     
    918918        conditional_expression
    919919        | unary_expression assignment_operator assignment_expression
    920                 { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
     920                {
     921//                      if ( $2 == OperKinds::AtAssn ) {
     922//                              SemanticError( yylloc, "C @= assignment is currently unimplemented." ); $$ = nullptr;
     923//                      } else {
     924                                $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) );
     925//                      } // if
     926                }
    921927        | unary_expression '=' '{' initializer_list_opt comma_opt '}'
    922928                { SemanticError( yylloc, "Initializer assignment is currently unimplemented." ); $$ = nullptr; }
     
    959965
    960966tuple_expression_list:
    961         assignment_expression_opt
    962         | tuple_expression_list ',' assignment_expression_opt
     967        assignment_expression
     968        | '@'                                                                                           // CFA
     969                { SemanticError( yylloc, "Eliding tuple element with '@' is currently unimplemented." ); $$ = nullptr; }
     970        | tuple_expression_list ',' assignment_expression
    963971                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     972        | tuple_expression_list ',' '@'
     973                { SemanticError( yylloc, "Eliding tuple element with '@' is currently unimplemented." ); $$ = nullptr; }
    964974        ;
    965975
     
    10701080        IF '(' if_control_expression ')' statement                      %prec THEN
    10711081                // explicitly deal with the shift/reduce conflict on if/else
    1072                 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); }
     1082                { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), nullptr ) ); }
    10731083        | IF '(' if_control_expression ')' statement ELSE statement
    1074                 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); }
     1084                { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), maybe_build_compound( $7 ) ) ); }
    10751085        ;
    10761086
     
    11201130
    11211131case_clause:                                                                                    // CFA
    1122         case_label_list statement                                       { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
     1132        case_label_list statement                                       { $$ = $1->append_last_case( maybe_build_compound( $2 ) ); }
    11231133        ;
    11241134
     
    11381148iteration_statement:
    11391149        WHILE '(' push if_control_expression ')' statement pop
    1140                 { $$ = new StatementNode( build_while( $4, $6 ) ); }
     1150                { $$ = new StatementNode( build_while( $4, maybe_build_compound( $6 ) ) ); }
    11411151        | WHILE '(' ')' statement                                                       // CFA => while ( 1 )
    1142                 { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), $4 ) ); }
     1152                { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); }
    11431153        | DO statement WHILE '(' comma_expression ')' ';'
    1144                 { $$ = new StatementNode( build_do_while( $5, $2 ) ); }
     1154                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
    11451155        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    1146                 { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), $2 ) ); }
     1156                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); }
    11471157        | FOR '(' push for_control_expression_list ')' statement pop
    1148                 { $$ = new StatementNode( build_for( $4, $6 ) ); }
     1158                { $$ = new StatementNode( build_for( $4, maybe_build_compound( $6 ) ) ); }
    11491159        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
    1150                 { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), $4 ) ); }
     1160                { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); }
    11511161        ;
    11521162
     
    11851195                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11861196                                                OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1187         | '=' comma_expression                                                                  // CFA
     1197        | '=' comma_expression                                                          // CFA
    11881198                { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11891199                                                OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    11921202        | comma_expression inclexcl comma_expression '~' comma_expression // CFA
    11931203                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); }
     1204        | comma_expression ';'                                                          // CFA
     1205                { $$ = forCtrl( new ExpressionNode( build_constantInteger( *new string( "0u" ) ) ), $1, nullptr, OperKinds::LThan, nullptr, nullptr ); }
    11941206        | comma_expression ';' comma_expression                         // CFA
    11951207                { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11961208                                                OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    1197         | comma_expression ';' '=' comma_expression                             // CFA
     1209        | comma_expression ';' '=' comma_expression                     // CFA
    11981210                { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11991211                                                OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    12591271        | RETURN '{' initializer_list_opt comma_opt '}' ';'
    12601272                { SemanticError( yylloc, "Initializer return is currently unimplemented." ); $$ = nullptr; }
    1261         // | SUSPEND ';'
    1262         //      { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; }
    1263         // | SUSPEND compound_statement ';'
    1264         //      { SemanticError( yylloc, "Suspend expression is currently unimplemented." ); $$ = nullptr; }
     1273        | SUSPEND ';'
     1274                { $$ = new StatementNode( build_suspend( nullptr ) ); }
     1275        | SUSPEND compound_statement
     1276                { $$ = new StatementNode( build_suspend( $2 ) ); }
     1277        | SUSPEND COROUTINE ';'
     1278                { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Coroutine ) ); }
     1279        | SUSPEND COROUTINE compound_statement
     1280                { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Coroutine ) ); }
     1281        | SUSPEND GENERATOR ';'
     1282                { $$ = new StatementNode( build_suspend( nullptr, SuspendStmt::Generator ) ); }
     1283        | SUSPEND GENERATOR compound_statement
     1284                { $$ = new StatementNode( build_suspend( $3, SuspendStmt::Generator ) ); }
    12651285        | THROW assignment_expression_opt ';'                           // handles rethrow
    12661286                { $$ = new StatementNode( build_throw( $2 ) ); }
     
    12851305// If MUTEX becomes a general qualifier, there are shift/reduce conflicts, so change syntax to "with mutex".
    12861306mutex_statement:
    1287         MUTEX '(' argument_expression_list ')' statement
     1307        MUTEX '(' argument_expression_list_opt ')' statement
    12881308                { SemanticError( yylloc, "Mutex statement is currently unimplemented." ); $$ = nullptr; }
    12891309        ;
     
    13021322        WAITFOR '(' cast_expression ')'
    13031323                { $$ = $3; }
    1304 //      | WAITFOR '(' cast_expression ',' argument_expression_list ')'
     1324//      | WAITFOR '(' cast_expression ',' argument_expression_list_opt ')'
    13051325//              { $$ = (ExpressionNode *)$3->set_last( $5 ); }
    1306         | WAITFOR '(' cast_expression_list ':' argument_expression_list ')'
     1326        | WAITFOR '(' cast_expression_list ':' argument_expression_list_opt ')'
    13071327                { $$ = (ExpressionNode *)($3->set_last( $5 )); }
    13081328        ;
     
    13111331        cast_expression
    13121332        | cast_expression_list ',' cast_expression
    1313                 { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     1333                // { $$ = (ExpressionNode *)($1->set_last( $3 )); }
     1334                { SemanticError( yylloc, "List of mutex member is currently unimplemented." ); $$ = nullptr; }
    13141335        ;
    13151336
     
    13201341waitfor_clause:
    13211342        when_clause_opt waitfor statement                                       %prec THEN
    1322                 { $$ = build_waitfor( $2, $3, $1 ); }
     1343                { $$ = build_waitfor( $2, maybe_build_compound( $3 ), $1 ); }
    13231344        | when_clause_opt waitfor statement WOR waitfor_clause
    1324                 { $$ = build_waitfor( $2, $3, $1, $5 ); }
     1345                { $$ = build_waitfor( $2, maybe_build_compound( $3 ), $1, $5 ); }
    13251346        | when_clause_opt timeout statement                                     %prec THEN
    1326                 { $$ = build_waitfor_timeout( $2, $3, $1 ); }
     1347                { $$ = build_waitfor_timeout( $2, maybe_build_compound( $3 ), $1 ); }
    13271348        | when_clause_opt ELSE statement
    1328                 { $$ = build_waitfor_timeout( nullptr, $3, $1 ); }
     1349                { $$ = build_waitfor_timeout( nullptr, maybe_build_compound( $3 ), $1 ); }
    13291350                // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
    13301351        | when_clause_opt timeout statement WOR ELSE statement
    13311352                { SemanticError( yylloc, "else clause must be conditional after timeout or timeout never triggered." ); $$ = nullptr; }
    13321353        | when_clause_opt timeout statement WOR when_clause ELSE statement
    1333                 { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); }
     1354                { $$ = build_waitfor_timeout( $2, maybe_build_compound( $3 ), $1, maybe_build_compound( $7 ), $5 ); }
    13341355        ;
    13351356
     
    16541675
    16551676typedef_expression:
    1656                 // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
     1677                // deprecated GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
    16571678        TYPEDEF identifier '=' assignment_expression
    16581679                {
    1659                         // $$ = DeclarationNode::newName( 0 );                  // unimplemented
    1660                         SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr;
     1680                        SemanticError( yylloc, "Typedef expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
    16611681                }
    16621682        | typedef_expression pop ',' push identifier '=' assignment_expression
    16631683                {
    1664                         // $$ = DeclarationNode::newName( 0 );                  // unimplemented
    1665                         SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr;
    1666                 }
    1667         ;
    1668 
    1669 //c_declaration:
    1670 //      declaring_list pop ';'
    1671 //      | typedef_declaration pop ';'
    1672 //      | typedef_expression pop ';'                                            // GCC, naming expression type
    1673 //      | sue_declaration_specifier pop ';'
    1674 //      ;
    1675 //
    1676 //declaring_list:
    1677 //              // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static
    1678 //              // storage-class
    1679 //       declarator asm_name_opt initializer_opt
    1680 //              {
    1681 //                      typedefTable.addToEnclosingScope( IDENTIFIER );
    1682 //                      $$ = ( $2->addType( $1 ))->addAsmName( $3 )->addInitializer( $4 );
    1683 //              }
    1684 //      | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt
    1685 //              {
    1686 //                      typedefTable.addToEnclosingScope( IDENTIFIER );
    1687 //                      $$ = $1->appendList( $1->cloneBaseType( $4->addAsmName( $5 )->addInitializer( $6 ) ) );
    1688 //              }
    1689 //      ;
     1684                        SemanticError( yylloc, "Typedef expression is deprecated, use typeof(...) instead." ); $$ = nullptr;
     1685                }
     1686        ;
    16901687
    16911688c_declaration:
     
    16931690                { $$ = distAttr( $1, $2 ); }
    16941691        | typedef_declaration
    1695         | typedef_expression                                                            // GCC, naming expression type
     1692        | typedef_expression                                                            // deprecated GCC, naming expression type
    16961693        | sue_declaration_specifier
    16971694        ;
     
    20722069                { yyy = true; $$ = AggregateDecl::Union; }
    20732070        | EXCEPTION                                                                                     // CFA
    2074                 { yyy = true; $$ = AggregateDecl::Exception; }
     2071                // { yyy = true; $$ = AggregateDecl::Exception; }
     2072                { SemanticError( yylloc, "exception aggregate is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    20752073        ;
    20762074
    20772075aggregate_control:                                                                              // CFA
    2078         GENERATOR
    2079                 { yyy = true; $$ = AggregateDecl::Coroutine; }
     2076        MONITOR
     2077                { yyy = true; $$ = AggregateDecl::Monitor; }
     2078        | MUTEX STRUCT
     2079                { yyy = true; $$ = AggregateDecl::Monitor; }
     2080        | GENERATOR
     2081                { yyy = true; $$ = AggregateDecl::Generator; }
     2082        | MUTEX GENERATOR
     2083                { SemanticError( yylloc, "monitor generator is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    20802084        | COROUTINE
    20812085                { yyy = true; $$ = AggregateDecl::Coroutine; }
    2082         | MONITOR
    2083                 { yyy = true; $$ = AggregateDecl::Monitor; }
     2086        | MUTEX COROUTINE
     2087                { SemanticError( yylloc, "monitor coroutine is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    20842088        | THREAD
    20852089                { yyy = true; $$ = AggregateDecl::Thread; }
     2090        | MUTEX THREAD
     2091                { SemanticError( yylloc, "monitor thread is currently unimplemented." ); $$ = AggregateDecl::NoAggregate; }
    20862092        ;
    20872093
     
    24062412// Overloading: function, data, and operator identifiers may be overloaded.
    24072413//
    2408 // Type declarations: "type" is used to generate new types for declaring objects. Similarly, "dtype" is used for object
     2414// Type declarations: "otype" is used to generate new types for declaring objects. Similarly, "dtype" is used for object
    24092415//     and incomplete types, and "ftype" is used for function types. Type declarations with initializers provide
    24102416//     definitions of new types. Type declarations with storage class "extern" provide opaque types.
     
    24352441        type_class identifier_or_type_name
    24362442                { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
    2437           type_initializer_opt assertion_list_opt
     2443        type_initializer_opt assertion_list_opt
    24382444                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    24392445        | type_specifier identifier_parameter_declarator
     
    24622468        assertion
    24632469        | assertion_list assertion
    2464                 { $$ = $1 ? $1->appendList( $2 ) : $2; }
     2470                { $$ = $1->appendList( $2 ); }
    24652471        ;
    24662472
     
    27492755        | attr_name
    27502756                { $$ = DeclarationNode::newAttribute( $1 ); }
    2751         | attr_name '(' argument_expression_list ')'
     2757        | attr_name '(' argument_expression_list_opt ')'
    27522758                { $$ = DeclarationNode::newAttribute( $1, $3 ); }
    27532759        ;
Note: See TracChangeset for help on using the changeset viewer.