Changeset 5bd0aad for src/Parser


Ignore:
Timestamp:
Jul 17, 2017, 3:54:08 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
969b3fe
Parents:
e60e0dc (diff), 59e86eb (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

Location:
src/Parser
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    re60e0dc r5bd0aad  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 15:27:00 2017
    13 // Update Count     : 1019
     12// Last Modified On : Fri Jul 14 16:55:00 2017
     13// Update Count     : 1020
    1414//
    1515
     
    253253        newnode->type->aggregate.fields = fields;
    254254        newnode->type->aggregate.body = body;
     255        newnode->type->aggregate.tagged = false;
     256        newnode->type->aggregate.parent = nullptr;
    255257        return newnode;
    256258} // DeclarationNode::newAggregate
     
    273275        return newnode;
    274276} // DeclarationNode::newEnumConstant
     277
     278DeclarationNode * DeclarationNode::newTreeStruct( Aggregate kind, const string * name, const string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     279        assert( name );
     280        DeclarationNode * newnode = new DeclarationNode;
     281        newnode->type = new TypeData( TypeData::Aggregate );
     282        newnode->type->aggregate.kind = kind;
     283        newnode->type->aggregate.name = name;
     284        newnode->type->aggregate.actuals = actuals;
     285        newnode->type->aggregate.fields = fields;
     286        newnode->type->aggregate.body = body;
     287        newnode->type->aggregate.tagged = true;
     288        newnode->type->aggregate.parent = parent;
     289        return newnode;
     290} // DeclarationNode::newTreeStruct
    275291
    276292DeclarationNode * DeclarationNode::newName( string * name ) {
  • src/Parser/ExpressionNode.cc

    re60e0dc r5bd0aad  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 28 21:08:15 2017
    13 // Update Count     : 542
     12// Last Modified On : Sat Jul 15 16:09:04 2017
     13// Update Count     : 549
    1414//
    1515
     
    231231}
    232232
     233// Must harmonize with OperKinds.
    233234static const char *OperName[] = {
    234235        // diadic
    235         "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
     236        "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
    236237        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    237         "?=?", "?@=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
     238        "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
    238239        "?[?]", "...",
    239240        // monadic
  • src/Parser/ParseNode.h

    re60e0dc r5bd0aad  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jun 12 13:00:00 2017
    13 // Update Count     : 779
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 15 16:00:48 2017
     13// Update Count     : 785
    1414//
    1515
     
    141141};
    142142
     143// Must harmonize with OperName.
    143144enum class OperKinds {
    144145        // diadic
    145         SizeOf, AlignOf, OffsetOf, Plus, Minus, Mul, Div, Mod, Or, And,
     146        SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,
    146147        BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    147         Assign, AtAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
     148        Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
    148149        Index, Range,
    149150        // monadic
     
    248249        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
    249250
     251        // Perhaps this would best fold into newAggragate.
     252        static DeclarationNode * newTreeStruct( Aggregate kind, const std::string * name, const std::string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body );
     253
    250254        DeclarationNode();
    251255        ~DeclarationNode();
     
    332336
    333337        static UniqueName anonymous;
     338
     339        // Temp to test TreeStruct
     340        const std::string * parent_name;
    334341}; // DeclarationNode
    335342
  • src/Parser/TypeData.cc

    re60e0dc r5bd0aad  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 15:28:00 2017
    13 // Update Count     : 564
     12// Last Modified On : Fri Jul 14 16:58:00 2017
     13// Update Count     : 565
    1414//
    1515
     
    6363                aggregate.fields = nullptr;
    6464                aggregate.body = false;
     65                aggregate.tagged = false;
     66                aggregate.parent = nullptr;
    6567                break;
    6668          case AggregateInst:
     
    121123                delete aggregate.actuals;
    122124                delete aggregate.fields;
     125                delete aggregate.parent;
    123126                // delete aggregate;
    124127                break;
     
    192195                newtype->aggregate.kind = aggregate.kind;
    193196                newtype->aggregate.body = aggregate.body;
     197                newtype->aggregate.tagged = aggregate.tagged;
     198                newtype->aggregate.parent = aggregate.parent ? new string( *aggregate.parent ) : nullptr;
    194199                break;
    195200          case AggregateInst:
     
    619624        switch ( td->aggregate.kind ) {
    620625          case DeclarationNode::Struct:
     626                if ( td->aggregate.tagged ) {
     627                        at = new StructDecl( *td->aggregate.name, td->aggregate.parent, attributes, linkage );
     628                        buildForall( td->aggregate.params, at->get_parameters() );
     629                        break;
     630                }
    621631          case DeclarationNode::Coroutine:
    622632          case DeclarationNode::Monitor:
  • src/Parser/TypeData.h

    re60e0dc r5bd0aad  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 15:29:00 2017
    13 // Update Count     : 186
     12// Last Modified On : Fri Jul 14 16:57:00 2017
     13// Update Count     : 187
    1414//
    1515
     
    3131                DeclarationNode * fields;
    3232                bool body;
     33
     34                bool tagged;
     35                const std::string * parent;
    3336        };
    3437
  • src/Parser/lex.ll

    re60e0dc r5bd0aad  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Wed Jul 12 18:04:44 2017
    13  * Update Count     : 535
     12 * Last Modified On : Sat Jul 15 15:46:34 2017
     13 * Update Count     : 542
    1414 */
    1515
     
    125125op_unary {op_unary_only}|{op_unary_binary}|{op_unary_pre_post}
    126126
    127 op_binary_only "/"|"%"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"&="|"|="|"^="|"<<="|">>="
     127op_binary_only "/"|"%"|"\\"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"\\="|"&="|"|="|"^="|"<<="|">>="
    128128op_binary_over {op_unary_binary}|{op_binary_only}
    129129                                // op_binary_not_over "?"|"->"|"."|"&&"|"||"|"@="
     
    136136
    137137%%
    138                                    /* line directives */
     138                                /* line directives */
    139139^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" {
    140140        /* " stop highlighting */
     
    337337"-"                             { ASCIIOP_RETURN(); }
    338338"*"                             { ASCIIOP_RETURN(); }
     339"\\"                    { ASCIIOP_RETURN(); }                                   // CFA, exponentiation
    339340"/"                             { ASCIIOP_RETURN(); }
    340341"%"                             { ASCIIOP_RETURN(); }
     
    361362"+="                    { NAMEDOP_RETURN(PLUSassign); }
    362363"-="                    { NAMEDOP_RETURN(MINUSassign); }
     364"\\="                   { NAMEDOP_RETURN(EXPassign); }                  // CFA, exponentiation
    363365"*="                    { NAMEDOP_RETURN(MULTassign); }
    364366"/="                    { NAMEDOP_RETURN(DIVassign); }
  • src/Parser/parser.yy

    re60e0dc r5bd0aad  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 13 14:38:54 2017
    13 // Update Count     : 2431
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jul 17 12:17:00 2017
     13// Update Count     : 2455
    1414//
    1515
     
    151151%token ELLIPSIS                                                                                 // ...
    152152
    153 %token MULTassign       DIVassign       MODassign                               // *=   /=      %=/
     153%token EXPassign        MULTassign      DIVassign       MODassign       // \=   *=      /=      %=
    154154%token PLUSassign       MINUSassign                                                     // +=   -=
    155155%token LSassign         RSassign                                                        // <<=  >>=
     
    168168%type<op> ptrref_operator                               unary_operator                          assignment_operator
    169169%type<en> primary_expression                    postfix_expression                      unary_expression
    170 %type<en> cast_expression                               multiplicative_expression       additive_expression                     shift_expression
    171 %type<en> relational_expression                 equality_expression                     AND_expression                          exclusive_OR_expression
    172 %type<en> inclusive_OR_expression               logical_AND_expression          logical_OR_expression           conditional_expression
    173 %type<en> constant_expression                   assignment_expression           assignment_expression_opt
     170%type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
     171%type<en> shift_expression                              relational_expression           equality_expression
     172%type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
     173%type<en> logical_AND_expression                logical_OR_expression
     174%type<en> conditional_expression                constant_expression                     assignment_expression           assignment_expression_opt
    174175%type<en> comma_expression                              comma_expression_opt
    175 %type<en> argument_expression_list              argument_expression                     assignment_opt
     176%type<en> argument_expression_list              argument_expression                     default_initialize_opt
    176177%type<fctl> for_control_expression
    177178%type<en> subrange
     
    573574        ;
    574575
     576exponential_expression:
     577        cast_expression
     578        | exponential_expression '\\' cast_expression
     579                { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); }
     580        ;
     581
    575582multiplicative_expression:
    576         cast_expression
    577         | multiplicative_expression '*' cast_expression
     583        exponential_expression
     584        | multiplicative_expression '*' exponential_expression
    578585                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    579         | multiplicative_expression '/' cast_expression
     586        | multiplicative_expression '/' exponential_expression
    580587                { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    581         | multiplicative_expression '%' cast_expression
     588        | multiplicative_expression '%' exponential_expression
    582589                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    583590        ;
     
    678685        '='                                                                                     { $$ = OperKinds::Assign; }
    679686        | ATassign                                                                      { $$ = OperKinds::AtAssn; }
     687        | EXPassign                                                                     { $$ = OperKinds::ExpAssn; }
    680688        | MULTassign                                                            { $$ = OperKinds::MulAssn; }
    681689        | DIVassign                                                                     { $$ = OperKinds::DivAssn; }
     
    972980                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
    973981
    974         | handler_key '(' push push exception_declaration pop ')' compound_statement pop
    975                 { $$ = new StatementNode( build_catch( $1, $5, nullptr, $8 ) ); }
    976         | handler_clause handler_key '(' push push exception_declaration pop ')' compound_statement pop
    977                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $9 ) ) ); }
     982        | handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     983                { $$ = new StatementNode( build_catch( $1, $5, nullptr, $9 ) ); }
     984        | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     985                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $10 ) ) ); }
     986        ;
     987
     988handler_predicate_opt:
     989        //empty
     990        | ';' conditional_expression
    978991        ;
    979992
     
    16671680        | aggregate_key attribute_list_opt typegen_name         // CFA
    16681681                { $$ = $3->addQualifiers( $2 ); }
     1682
     1683// Temp, testing TreeStruct
     1684    | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name
     1685        {
     1686            typedefTable.makeTypedef( *$4 );            // create typedef
     1687            if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $
     1688            forall = false;                             // reset
     1689        }
     1690      '{' field_declaration_list '}'
     1691        {
     1692            $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,
     1693                $4, nullptr, nullptr, $7, true )->addQualifiers( $3 );
     1694        }
     1695    | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name TYPEDEFname
     1696        {
     1697            typedefTable.makeTypedef( *$4 );            // create typedef
     1698            if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $
     1699            forall = false;                             // reset
     1700        }
     1701      '{' field_declaration_list '}'
     1702        {
     1703            $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,
     1704                $4, $5, nullptr, $8, true )->addQualifiers( $3 );
     1705        }
    16691706        ;
    16701707
     
    18451882cfa_parameter_declaration:                                                              // CFA, new & old style parameter declaration
    18461883        parameter_declaration
    1847         | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt
     1884        | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt
    18481885                { $$ = $1->addName( $2 ); }
    1849         | cfa_abstract_tuple identifier_or_type_name assignment_opt
     1886        | cfa_abstract_tuple identifier_or_type_name default_initialize_opt
    18501887                // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator).
    18511888                { $$ = $1->addName( $2 ); }
    1852         | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt
     1889        | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt
    18531890                { $$ = $2->addName( $3 )->addQualifiers( $1 ); }
    18541891        | cfa_function_specifier
     
    18671904parameter_declaration:
    18681905                // No SUE declaration in parameter list.
    1869         declaration_specifier_nobody identifier_parameter_declarator assignment_opt
     1906        declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt
    18701907                {
    18711908                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    18721909                        $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
    18731910                }
    1874         | declaration_specifier_nobody type_parameter_redeclarator assignment_opt
     1911        | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt
    18751912                {
    18761913                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    18801917
    18811918abstract_parameter_declaration:
    1882         declaration_specifier_nobody assignment_opt
     1919        declaration_specifier_nobody default_initialize_opt
    18831920                { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); }
    1884         | declaration_specifier_nobody abstract_parameter_declarator assignment_opt
     1921        | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt
    18851922                { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); }
    18861923        ;
     
    30453082        ;
    30463083
    3047 assignment_opt:
     3084default_initialize_opt:
    30483085        // empty
    30493086                { $$ = nullptr; }
Note: See TracChangeset for help on using the changeset viewer.