Ignore:
Timestamp:
Feb 10, 2020, 11:17:38 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
3966d9a, 41efd33
Parents:
807a632 (diff), d231700 (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

    r807a632 r3b56166  
    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 Feb  1 10:04:40 2020
     13// Update Count     : 4440
    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...
     
    211212} // forCtrl
    212213
    213 
    214214bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
    215215
     
    237237        ExpressionNode * en;
    238238        DeclarationNode * decl;
    239         DeclarationNode::Aggregate aggKey;
    240         DeclarationNode::TypeClass tclass;
     239        AggregateDecl::Aggregate aggKey;
     240        TypeDecl::Kind tclass;
    241241        StatementNode * sn;
    242242        WaitForStmt * wfs;
     
    323323%type<op> ptrref_operator                               unary_operator                          assignment_operator
    324324%type<en> primary_expression                    postfix_expression                      unary_expression
    325 %type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
     325%type<en> cast_expression_list                  cast_expression                         exponential_expression          multiplicative_expression       additive_expression
    326326%type<en> shift_expression                              relational_expression           equality_expression
    327327%type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
     
    365365%type<decl> abstract_parameter_declaration
    366366
    367 %type<aggKey> aggregate_key
     367%type<aggKey> aggregate_key aggregate_data aggregate_control
    368368%type<decl> aggregate_type aggregate_type_nobody
    369369
     
    579579        | '(' compound_statement ')'                                            // GCC, lambda expression
    580580                { $$ = 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 ) ); }
    591581        | type_name '.' identifier                                                      // CFA, nested type
    592582                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
     
    642632        | postfix_expression '(' argument_expression_list ')'
    643633                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
     634        | postfix_expression '`' identifier                                     // CFA, postfix call
     635                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     636        | constant '`' identifier                                                       // CFA, postfix call
     637                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), $1 ) ); }
     638        | string_literal '`' identifier                                         // CFA, postfix call
     639                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $3 ) ), new ExpressionNode( $1 ) ) ); }
    644640        | postfix_expression '.' identifier
    645641                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
     
    650646        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    651647                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
     648        | postfix_expression '.' aggregate_control
     649                { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); }
    652650        | postfix_expression ARROW identifier
    653651                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    664662        | '(' type_no_function ')' '@' '{' initializer_list_opt comma_opt '}' // CFA, explicit C compound-literal
    665663                { $$ = new ExpressionNode( build_compoundLiteral( $2, (new InitializerNode( $6, true ))->set_maybeConstructed( false ) ) ); }
    666         | '^' primary_expression '{' argument_expression_list '}' // CFA
     664        | '^' primary_expression '{' argument_expression_list '}' // CFA, destructor call
    667665                {
    668666                        Token fn;
     
    677675        | argument_expression
    678676        | argument_expression_list ',' argument_expression
    679                 { $$ = (ExpressionNode *)( $1->set_last( $3 )); }
     677                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    680678        ;
    681679
     
    689687field_name_list:                                                                                // CFA, tuple field selector
    690688        field
    691         | field_name_list ',' field                                     { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     689        | field_name_list ',' field                                     { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    692690        ;
    693691
     
    793791        | '(' type_no_function ')' cast_expression
    794792                { $$ = 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 ) ); }
     793        | '(' aggregate_control '&' ')' cast_expression         // CFA
     794                { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); }
    804795                // VIRTUAL cannot be opt because of look ahead issues
    805796        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    965956                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); }
    966957        | '[' push assignment_expression pop ',' tuple_expression_list ']'
    967                 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $6 ) ) ); }
     958                { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)($3->set_last( $6 ) ) )); }
    968959        ;
    969960
     
    971962        assignment_expression_opt
    972963        | tuple_expression_list ',' assignment_expression_opt
    973                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     964                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    974965        ;
    975966
     
    11951186                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    11961187                                                OperKinds::LThan, $1->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1188        | '=' comma_expression                                                                  // CFA
     1189                { $$ = forCtrl( $2, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1190                                                OperKinds::LEThan, $2->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    11971191        | comma_expression inclexcl comma_expression            // CFA
    11981192                { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    12021196                { $$ = forCtrl( $3, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
    12031197                                                OperKinds::LThan, $3->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     1198        | comma_expression ';' '=' comma_expression                             // CFA
     1199                { $$ = forCtrl( $4, $1, new ExpressionNode( build_constantInteger( *new string( "0" ) ) ),
     1200                                                OperKinds::LEThan, $4->clone(), new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
    12041201        | comma_expression ';' comma_expression inclexcl comma_expression // CFA
    12051202                { $$ = forCtrl( $3, $1, $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ); }
     
    13061303        WAITFOR '(' cast_expression ')'
    13071304                { $$ = $3; }
    1308         | WAITFOR '(' cast_expression ',' argument_expression_list ')'
    1309                 { $$ = (ExpressionNode *)$3->set_last( $5 ); }
     1305//      | WAITFOR '(' cast_expression ',' argument_expression_list ')'
     1306//              { $$ = (ExpressionNode *)$3->set_last( $5 ); }
     1307        | WAITFOR '(' cast_expression_list ':' argument_expression_list ')'
     1308                { $$ = (ExpressionNode *)($3->set_last( $5 )); }
     1309        ;
     1310
     1311cast_expression_list:
     1312        cast_expression
     1313        | cast_expression_list ',' cast_expression
     1314                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    13101315        ;
    13111316
     
    14181423        asm_operand
    14191424        | asm_operands_list ',' asm_operand
    1420                 { $$ = (ExpressionNode *)$1->set_last( $3 ); }
     1425                { $$ = (ExpressionNode *)($1->set_last( $3 )); }
    14211426        ;
    14221427
    14231428asm_operand:                                                                                    // GCC
    14241429        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 ) ) ); }
     1430                { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild< Expression >( $3 ) ) ); }
     1431        | '[' IDENTIFIER ']' string_literal '(' constant_expression ')'
     1432                { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild< Expression >( $6 ) ) ); }
    14281433        ;
    14291434
     
    14341439                { $$ = new ExpressionNode( $1 ); }
    14351440        | asm_clobbers_list_opt ',' string_literal
    1436                 // set_last returns ParseNode *
    1437                 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }
     1441                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( $3 ) )); }
    14381442        ;
    14391443
     
    20592063
    20602064aggregate_key:
     2065        aggregate_data
     2066        | aggregate_control
     2067        ;
     2068
     2069aggregate_data:
    20612070        STRUCT
    2062                 { yyy = true; $$ = DeclarationNode::Struct; }
     2071                { yyy = true; $$ = AggregateDecl::Struct; }
    20632072        | UNION
    2064                 { yyy = true; $$ = DeclarationNode::Union; }
    2065         | EXCEPTION
    2066                 { yyy = true; $$ = DeclarationNode::Exception; }
    2067         | GENERATOR
    2068                 { yyy = true; $$ = DeclarationNode::Coroutine; }
     2073                { yyy = true; $$ = AggregateDecl::Union; }
     2074        | EXCEPTION                                                                                     // CFA
     2075                { yyy = true; $$ = AggregateDecl::Exception; }
     2076        ;
     2077
     2078aggregate_control:                                                                              // CFA
     2079        GENERATOR
     2080                { yyy = true; $$ = AggregateDecl::Coroutine; }
    20692081        | COROUTINE
    2070                 { yyy = true; $$ = DeclarationNode::Coroutine; }
     2082                { yyy = true; $$ = AggregateDecl::Coroutine; }
    20712083        | MONITOR
    2072                 { yyy = true; $$ = DeclarationNode::Monitor; }
     2084                { yyy = true; $$ = AggregateDecl::Monitor; }
    20732085        | THREAD
    2074                 { yyy = true; $$ = DeclarationNode::Thread; }
     2086                { yyy = true; $$ = AggregateDecl::Thread; }
    20752087        ;
    20762088
     
    20962108                        distInl( $3 );
    20972109                }
     2110        | INLINE aggregate_control ';'                                          // CFA
     2111                { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
    20982112        | typedef_declaration ';'                                                       // CFA
    20992113        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
     
    23482362        | initializer_list_opt ',' initializer          { $$ = (InitializerNode *)( $1->set_last( $3 ) ); }
    23492363        | initializer_list_opt ',' designation initializer
    2350                 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); }
     2364                { $$ = (InitializerNode *)($1->set_last( $4->set_designators( $3 ) )); }
    23512365        ;
    23522366
     
    23702384        designator
    23712385        | designator_list designator
    2372                 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); }
     2386                { $$ = (ExpressionNode *)($1->set_last( $2 )); }
    23732387        //| designator_list designator                                          { $$ = new ExpressionNode( $1, $2 ); }
    23742388        ;
     
    24262440        | type_specifier identifier_parameter_declarator
    24272441        | assertion_list
    2428                 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
     2442                { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }
    24292443        ;
    24302444
    24312445type_class:                                                                                             // CFA
    24322446        OTYPE
    2433                 { $$ = DeclarationNode::Otype; }
     2447                { $$ = TypeDecl::Otype; }
    24342448        | DTYPE
    2435                 { $$ = DeclarationNode::Dtype; }
     2449                { $$ = TypeDecl::Dtype; }
    24362450        | FTYPE
    2437                 { $$ = DeclarationNode::Ftype; }
     2451                { $$ = TypeDecl::Ftype; }
    24382452        | TTYPE
    2439                 { $$ = DeclarationNode::Ttype; }
     2453                { $$ = TypeDecl::Ttype; }
    24402454        ;
    24412455
     
    24672481                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $1->build()) ); $$ = nullptr; }
    24682482        | type_list ',' type
    2469                 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) ) ); }
     2483                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
    24702484        | type_list ',' assignment_expression
    24712485                { SemanticError( yylloc, toString("Expression generic parameters are currently unimplemented: ", $3->build()) ); $$ = nullptr; }
     
    25782592                {
    25792593                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2580                         linkage = LinkageSpec::linkageUpdate( yylloc, linkage, $2 );
     2594                        linkage = LinkageSpec::update( yylloc, linkage, $2 );
    25812595                }
    25822596          '{' up external_definition_list_opt down '}'
Note: See TracChangeset for help on using the changeset viewer.