Ignore:
Timestamp:
Aug 19, 2015, 3:59:45 PM (10 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
830c21a
Parents:
18997b9 (diff), 4aa0858 (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 'override-autogen' into ctor

Conflicts:

src/Parser/ParseNode.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r18997b9 r353d168  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 16 16:25:12 2015
    13 // Update Count     : 1267
     12// Last Modified On : Tue Aug 11 16:01:49 2015
     13// Update Count     : 1350
    1414//
    1515
     
    115115        StatementNode *sn;
    116116        ConstantNode *constant;
     117        LabelNode *label;
    117118        InitializerNode *in;
     119        bool flag;
    118120}
    119121
     
    134136%type<en> argument_expression_list              argument_expression                     for_control_expression          assignment_opt
    135137%type<en> subrange
     138%type<en> asm_operands_opt asm_operands_list asm_operand
     139%type<label> label_list
     140%type<constant> asm_clobbers_list_opt
     141%type<flag> asm_volatile_opt
    136142
    137143// statements
     
    332338        | zero_one
    333339                { $$ = new VarRefNode( $1 ); }
    334         | constant
    335                 { $$ = $1; }
    336         | string_literal_list
    337                 { $$ = $1; }
    338340        | '(' comma_expression ')'
    339341                { $$ = $2; }
     
    378380        | assignment_expression
    379381        | no_attr_identifier ':' assignment_expression
    380                 { $$ = $3->set_asArgName( $1 ); }
     382                { $$ = $3->set_argName( $1 ); }
    381383                // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient
    382384                // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used
    383385                // with an appropriate semantic check.
    384386        | '[' push assignment_expression pop ']' ':' assignment_expression
    385                 { $$ = $7->set_asArgName( $3 ); }
     387                { $$ = $7->set_argName( $3 ); }
    386388        | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
    387                 { $$ = $9->set_asArgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
     389                { $$ = $9->set_argName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
    388390        ;
    389391
     
    408410unary_expression:
    409411        postfix_expression
     412        // first location where constant/string can have operator applied: sizeof 3/sizeof "abc"
     413        // still requires semantics checks, e.g., ++3, 3--, *3, &&3
     414        | constant
     415                { $$ = $1; }
     416        | string_literal_list
     417                { $$ = $1; }
    410418        | ICR unary_expression
    411419                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); }
     
    635643                // requires its own scope
    636644          push push
    637           label_declaration_opt                                                         // GCC, local labels
     645          local_label_declaration_opt                                           // GCC, local labels
    638646          block_item_list pop '}'                                                       // C99, intermix declarations and statements
    639647                { $$ = new CompoundStmtNode( $5 ); }
     
    754762
    755763fall_through:                                                                                   // CFA
    756         FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
    757         | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
     764        FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru ); }
     765        | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru ); }
    758766        ;
    759767
     
    783791        | CONTINUE ';'
    784792                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    785                 { $$ = new StatementNode( StatementNode::Continue, 0, 0 ); }
     793                { $$ = new StatementNode( StatementNode::Continue ); }
    786794        | CONTINUE no_attr_identifier ';'                                       // CFA, multi-level continue
    787795                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     
    790798        | BREAK ';'
    791799                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    792                 { $$ = new StatementNode( StatementNode::Break, 0, 0 ); }
     800                { $$ = new StatementNode( StatementNode::Break ); }
    793801        | BREAK no_attr_identifier ';'                                          // CFA, multi-level exit
    794802                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     
    800808                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    801809        | THROW ';'
    802                 { $$ = new StatementNode( StatementNode::Throw, 0, 0 ); }
     810                { $$ = new StatementNode( StatementNode::Throw ); }
    803811        ;
    804812
     
    863871
    864872asm_statement:
    865         ASM type_qualifier_list_opt '(' constant_expression ')' ';'
    866                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    867         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ')' ';' // remaining GCC
    868                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    869         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    870                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    871         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list ')' ';'
    872                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
     873        ASM asm_volatile_opt '(' string_literal_list ')' ';'
     874                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, 0 ); }
     875        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC
     876                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6 ); }
     877        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';'
     878                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8 ); }
     879        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
     880                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10 ); }
     881        | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
     882        { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); }
     883        ;
     884
     885asm_volatile_opt:                                                                               // GCC
     886        // empty
     887                { $$ = false; }
     888        | VOLATILE
     889                { $$ = true; }
    873890        ;
    874891
    875892asm_operands_opt:                                                                               // GCC
    876893        // empty
     894                { $$ = 0; }                                                                             // use default argument
    877895        | asm_operands_list
    878896        ;
     
    881899        asm_operand
    882900        | asm_operands_list ',' asm_operand
     901                { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    883902        ;
    884903
    885904asm_operand:                                                                                    // GCC
    886         STRINGliteral '(' constant_expression ')'       {}
    887         ;
    888 
    889 asm_clobbers_list:                                                                              // GCC
    890         STRINGliteral                                                           {}
    891         | asm_clobbers_list ',' STRINGliteral
     905        string_literal_list '(' constant_expression ')'
     906                { $$ = new AsmExprNode( 0, $1, $3 ); }
     907        | '[' constant_expression ']' string_literal_list '(' constant_expression ')'
     908                { $$ = new AsmExprNode( $2, $4, $6 ); }
     909        ;
     910
     911asm_clobbers_list_opt:                                                                          // GCC
     912        // empty
     913                { $$ = 0; }                                                                             // use default argument
     914        | string_literal_list
     915                { $$ = $1; }
     916        | asm_clobbers_list_opt ',' string_literal_list
     917                { $$ = (ConstantNode *)$1->set_link( $3 ); }
     918        ;
     919
     920label_list:
     921        no_attr_identifier
     922                { $$ = new LabelNode(); $$->append_label( $1 ); }
     923        | label_list ',' no_attr_identifier
     924                { $$ = $1; $1->append_label( $3 ); }
    892925        ;
    893926
     
    918951        ;
    919952
    920 label_declaration_opt:                                                                  // GCC, local label
     953local_label_declaration_opt:                                                    // GCC, local label
    921954        // empty
    922         | label_declaration_list
    923         ;
    924 
    925 label_declaration_list:                                                                 // GCC, local label
    926         LABEL label_list ';'
    927         | label_declaration_list LABEL label_list ';'
    928         ;
    929 
    930 label_list:                                                                                             // GCC, local label
    931         no_attr_identifier_or_type_name                 {}
    932         | label_list ',' no_attr_identifier_or_type_name {}
     955        | local_label_declaration_list
     956        ;
     957
     958local_label_declaration_list:                                                   // GCC, local label
     959        LABEL local_label_list ';'
     960        | local_label_declaration_list LABEL local_label_list ';'
     961        ;
     962
     963local_label_list:                                                                               // GCC, local label
     964        no_attr_identifier_or_type_name                         {}
     965        | local_label_list ',' no_attr_identifier_or_type_name {}
    933966        ;
    934967
     
    16601693
    16611694designator:
    1662         '.' no_attr_identifier_or_type_name                                     // C99, field name
    1663                 { $$ = new VarRefNode( $2 ); }
     1695        // only ".0" and ".1" allowed => semantic check
     1696        FLOATINGconstant
     1697                { $$ = new DesignatorNode( new VarRefNode( $1 ) ); }
     1698        | '.' no_attr_identifier_or_type_name                           // C99, field name
     1699                { $$ = new DesignatorNode( new VarRefNode( $2 ) ); }
    16641700        | '[' push assignment_expression pop ']'                        // C99, single array element
    16651701                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
    1666                 { $$ = $3; }
     1702                { $$ = new DesignatorNode( $3, true ); }
    16671703        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    1668                 { $$ = $3; }
     1704                { $$ = new DesignatorNode( $3, true ); }
    16691705        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1670                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ); }
     1706                { $$ = new DesignatorNode( new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ), true ); }
    16711707        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    1672                 { $$ = $4; }
     1708                { $$ = new DesignatorNode( $4 ); }
    16731709        ;
    16741710
Note: See TracChangeset for help on using the changeset viewer.