Ignore:
Timestamp:
Feb 25, 2020, 1:17:33 PM (6 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:
7dc2e015
Parents:
9fb8f01 (diff), dd9e1ca (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

    r9fb8f01 r3d5701e  
    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 : Fri Feb 21 14:47:29 2020
     13// Update Count     : 4468
    1414//
    1515
     
    5151using namespace std;
    5252
     53#include "SynTree/Declaration.h"
    5354#include "ParseNode.h"
    5455#include "TypedefTable.h"
    5556#include "TypeData.h"
    56 #include "LinkageSpec.h"
     57#include "SynTree/LinkageSpec.h"
    5758#include "Common/SemanticError.h"                                               // error_str
    5859#include "Common/utility.h"                                                             // for maybeMoveBuild, maybeBuild, CodeLo...
     
    165166} // rebindForall
    166167
    167 NameExpr * build_postfix_name( const string * name ) {
    168         NameExpr * new_name = build_varref( new string( "?`" + *name ) );
    169         delete name;
    170         return new_name;
     168string * build_postfix_name( string * name ) {
     169        *name = string("__postfix_func_") + *name;
     170        return name;
    171171} // build_postfix_name
    172172
     
    210210        } // if
    211211} // forCtrl
    212 
    213212
    214213bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
     
    237236        ExpressionNode * en;
    238237        DeclarationNode * decl;
    239         DeclarationNode::Aggregate aggKey;
    240         DeclarationNode::TypeClass tclass;
     238        AggregateDecl::Aggregate aggKey;
     239        TypeDecl::Kind tclass;
    241240        StatementNode * sn;
    242241        WaitForStmt * wfs;
     
    323322%type<op> ptrref_operator                               unary_operator                          assignment_operator
    324323%type<en> primary_expression                    postfix_expression                      unary_expression
    325 %type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
     324%type<en> cast_expression_list                  cast_expression                         exponential_expression          multiplicative_expression       additive_expression
    326325%type<en> shift_expression                              relational_expression           equality_expression
    327326%type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
     
    365364%type<decl> abstract_parameter_declaration
    366365
    367 %type<aggKey> aggregate_key
     366%type<aggKey> aggregate_key aggregate_data aggregate_control
    368367%type<decl> aggregate_type aggregate_type_nobody
    369368
     
    579578        | '(' compound_statement ')'                                            // GCC, lambda expression
    580579                { $$ = new ExpressionNode( new StmtExpr( dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >($2) ) ) ); }
    581         | constant '`' IDENTIFIER                                                       // CFA, postfix call
    582                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
    583         | string_literal '`' IDENTIFIER                                         // CFA, postfix call
    584                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
    585         | IDENTIFIER '`' IDENTIFIER                                                     // CFA, postfix call
    586                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( build_varref( $1 ) ) ) ); }
    587         | tuple '`' IDENTIFIER                                                          // CFA, postfix call
    588                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
    589         | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
    590                 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    591580        | type_name '.' identifier                                                      // CFA, nested type
    592581                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    642631        | postfix_expression '(' argument_expression_list ')'
    643632                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     633        | postfix_expression '`' identifier                                     // CFA, postfix call
     634                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
     635        | constant '`' identifier                                                       // CFA, postfix call
     636                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), $1 ) ); }
     637        | string_literal '`' identifier                                         // CFA, postfix call
     638                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( build_postfix_name( $3 ) ) ), new ExpressionNode( $1 ) ) ); }
    644639        | postfix_expression '.' identifier
    645640                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     
    650645        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    651646                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
     647        | postfix_expression '.' aggregate_control
     648                { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }
    652649        | postfix_expression ARROW identifier
    653650                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    664661        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    665662                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    666         | '^' primary_expression '{' argument_expression_list '}' // CFA
     663        | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call
    667664                {
    668665                        Token fn;
     
    677674        | argument_expression
    678675        | argument_expression_list ',' argument_expression
    679                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     676                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    680677        ;
    681678
     
    689686field_name_list:                                                                                // CFA, tuple field selector
    690687        field
    691         | field_name_list ',' field                                     { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     688        | field_name_list ',' field                                     { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    692689        ;
    693690
     
    793790        | '(' type_no_function ')' cast_expression
    794791                { $$ = 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 ) ); }
     792        | '(' aggregate_control '&' ')' cast_expression         // CFA
     793                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    804794                // VIRTUAL cannot be opt because of look ahead issues
    805795        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    965955                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    966956        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    967                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); }
     957                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }
    968958        ;
    969959
     
    971961        assignment_expression_opt
    972962        | tuple_expression_list ',' assignment_expression_opt
    973                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     963                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    974964        ;
    975965
     
    11951185                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11961186                                                OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1187        | '=' comma_expression                                                                  // CFA
     1188                { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1189                                                OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11971190        | comma_expression inclexcl comma_expression            // CFA
    11981191                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    12021195                { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    12031196                                                OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1197        | comma_expression ';' '=' comma_expression                             // CFA
     1198                { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1199                                                OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    12041200        | comma_expression ';' comma_expression inclexcl comma_expression // CFA
    12051201                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    13061302        WAITFOR '(' cast_expression ')'
    13071303                { $$ = $3; }
    1308         | WAITFOR '(' cast_expression ',' argument_expression_list ')'
    1309                 { $$ = (ExpressionNode *)$3->set_last( $5 ); }
     1304//      | WAITFOR '(' cast_expression ',' argument_expression_list ')'
     1305//              { $$ = (ExpressionNode *)$3->set_last( $5 ); }
     1306        | WAITFOR '(' cast_expression_list ':' argument_expression_list ')'
     1307                { $$ = (ExpressionNode *)($3->set_last( $5 )); }
     1308        ;
     1309
     1310cast_expression_list:
     1311        cast_expression
     1312        | cast_expression_list ',' cast_expression
     1313                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    13101314        ;
    13111315
     
    14181422        asm_operand
    14191423        | asm_operands_list ',' asm_operand
    1420                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     1424                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    14211425        ;
    14221426
    14231427asm_operand:                                                                                    // GCC
    14241428        string_literal '(' constant_expression ')'
    1425                 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ), $1, maybeMoveBuild< Expression >( $3 ) ) ); }
    1426         | '[' constant_expression ']' string_literal '(' constant_expression ')'
    1427                 { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( $2 ), $4, maybeMoveBuild< Expression >( $6 ) ) ); }
     1429                { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild< Expression >( $3 ) ) ); }
     1430        | '[' IDENTIFIER ']' string_literal '(' constant_expression ')'
     1431                { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild< Expression >( $6 ) ) ); }
    14281432        ;
    14291433
     
    14341438                { $$ = new ExpressionNode( $1 ); }
    14351439        | asm_clobbers_list_opt ',' string_literal
    1436                 // set_last returns ParseNode *
    1437                 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
     1440                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); }
    14381441        ;
    14391442
     
    15861589                // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be
    15871590                // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name.
    1588         cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
     1591        cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt
    15891592                // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator).
    1590                 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); }
    1591         | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')'
    1592                 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); }
     1593                { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 )->addQualifiers( $8 ); }
     1594        | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt
     1595                { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 )->addQualifiers( $8 ); }
    15931596        ;
    15941597
     
    20592062
    20602063aggregate_key:
     2064        aggregate_data
     2065        | aggregate_control
     2066        ;
     2067
     2068aggregate_data:
    20612069        STRUCT
    2062                 { yyy = true; $$ = DeclarationNode::Struct; }
     2070                { yyy = true; $$ = AggregateDecl::Struct; }
    20632071        | UNION
    2064                 { yyy = true; $$ = DeclarationNode::Union; }
    2065         | EXCEPTION
    2066                 { yyy = true; $$ = DeclarationNode::Exception; }
    2067         | GENERATOR
    2068                 { yyy = true; $$ = DeclarationNode::Coroutine; }
     2072                { yyy = true; $$ = AggregateDecl::Union; }
     2073        | EXCEPTION                                                                                     // CFA
     2074                { yyy = true; $$ = AggregateDecl::Exception; }
     2075        ;
     2076
     2077aggregate_control:                                                                              // CFA
     2078        GENERATOR
     2079                { yyy = true; $$ = AggregateDecl::Coroutine; }
    20692080        | COROUTINE
    2070                 { yyy = true; $$ = DeclarationNode::Coroutine; }
     2081                { yyy = true; $$ = AggregateDecl::Coroutine; }
    20712082        | MONITOR
    2072                 { yyy = true; $$ = DeclarationNode::Monitor; }
     2083                { yyy = true; $$ = AggregateDecl::Monitor; }
    20732084        | THREAD
    2074                 { yyy = true; $$ = DeclarationNode::Thread; }
     2085                { yyy = true; $$ = AggregateDecl::Thread; }
    20752086        ;
    20762087
     
    20962107                        distInl( $3 );
    20972108                }
     2109        | INLINE aggregate_control ';'                                          // CFA
     2110                { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
    20982111        | typedef_declaration ';'                                                       // CFA
    20992112        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
     
    23482361        | initializer_list_opt ',' initializer          { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
    23492362        | initializer_list_opt ',' designation initializer
    2350                 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
     2363                { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); }
    23512364        ;
    23522365
     
    23702383        designator
    23712384        | designator_list designator
    2372                 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
     2385                { $$ = (ExpressionNode *)($1->set_last( $2 )); }
    23732386        //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
    23742387        ;
     
    24262439        | type_specifier identifier_parameter_declarator
    24272440        | assertion_list
    2428                 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
     2441                { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
    24292442        ;
    24302443
    24312444type_class:                                                                                             // CFA
    24322445        OTYPE
    2433                 { $$ = DeclarationNode::Otype; }
     2446                { $$ = TypeDecl::Otype; }
    24342447        | DTYPE
    2435                 { $$ = DeclarationNode::Dtype; }
     2448                { $$ = TypeDecl::Dtype; }
    24362449        | FTYPE
    2437                 { $$ = DeclarationNode::Ftype; }
     2450                { $$ = TypeDecl::Ftype; }
    24382451        | TTYPE
    2439                 { $$ = DeclarationNode::Ttype; }
     2452                { $$ = TypeDecl::Ttype; }
    24402453        ;
    24412454
     
    24672480                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; }
    24682481        | type_list ',' type
    2469                 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); }
     2482                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
    24702483        | type_list ',' assignment_expression
    24712484                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; }
     
    25782591                {
    25792592                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2580                         linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
     2593                        linkage = LinkageSpec::update( yylloc, linkage, $2 );
    25812594                }
    25822595          '{' up external_definition_list_opt down '}'
Note: See TracChangeset for help on using the changeset viewer.