Changeset e307e12


Ignore:
Timestamp:
Dec 7, 2019, 10:49:05 AM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2cd949b, 98d6965d, f80f840
Parents:
e1990f1
Message:

generalize aggregate data and control in grammar, add aggregate-control field-name, add inline aggregate-control

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    re1990f1 re307e12  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  4 21:48:23 2019
    13 // Update Count     : 4364
     12// Last Modified On : Sat Dec  7 10:43:44 2019
     13// Update Count     : 4394
    1414//
    1515
     
    211211} // forCtrl
    212212
     213KeywordCastExpr::Target Aggregate2Target( DeclarationNode::Aggregate aggr ) {
     214        KeywordCastExpr::Target target;
     215        switch ( aggr ) {
     216          case DeclarationNode::Coroutine: target = KeywordCastExpr::Coroutine; break;
     217          case DeclarationNode::Monitor: target = KeywordCastExpr::Monitor; break;
     218          case DeclarationNode::Thread: target = KeywordCastExpr::Thread; break;
     219          default: abort();
     220        } // switch
     221        return target;
     222} // Aggregate2Target
     223
    213224
    214225bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
     
    365376%type<decl> abstract_parameter_declaration
    366377
    367 %type<aggKey> aggregate_key
     378%type<aggKey> aggregate_key aggregate_data aggregate_control
    368379%type<decl> aggregate_type aggregate_type_nobody
    369380
     
    650661        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    651662                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
     663        | postfix_expression '.' aggregate_control
     664                { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); }
    652665        | postfix_expression ARROW identifier
    653666                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    793806        | '(' type_no_function ')' cast_expression
    794807                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    795                 // keyword cast cannot be grouped because of reduction in aggregate_key
    796         | '(' GENERATOR '&' ')' cast_expression                         // CFA
    797                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
    798         | '(' COROUTINE '&' ')' cast_expression                         // CFA
    799                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
    800         | '(' THREAD '&' ')' cast_expression                            // CFA
    801                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); }
    802         | '(' MONITOR '&' ')' cast_expression                           // CFA
    803                 { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); }
     808        | '(' aggregate_control '&' ')' cast_expression         // CFA
     809                { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $2 ), $5 ) ); }
    804810                // VIRTUAL cannot be opt because of look ahead issues
    805811        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    20592065
    20602066aggregate_key:
     2067        aggregate_data
     2068        | aggregate_control
     2069        ;
     2070
     2071aggregate_data:
    20612072        STRUCT
    20622073                { yyy = true; $$ = DeclarationNode::Struct; }
    20632074        | UNION
    20642075                { yyy = true; $$ = DeclarationNode::Union; }
    2065         | EXCEPTION
     2076        | EXCEPTION                                                                                     // CFA
    20662077                { yyy = true; $$ = DeclarationNode::Exception; }
    2067         | GENERATOR
     2078        ;
     2079
     2080aggregate_control:                                                                              // CFA
     2081        GENERATOR
    20682082                { yyy = true; $$ = DeclarationNode::Coroutine; }
    20692083        | COROUTINE
     
    20962110                        distInl( $3 );
    20972111                }
     2112        | INLINE aggregate_control ';'                                          // CFA
     2113                { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
    20982114        | typedef_declaration ';'                                                       // CFA
    20992115        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
Note: See TracChangeset for help on using the changeset viewer.