Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r51b1202 r1db21619  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 11 16:01:49 2015
    13 // Update Count     : 1350
     12// Last Modified On : Thu Jul 16 16:25:12 2015
     13// Update Count     : 1267
    1414//
    1515
     
    115115        StatementNode *sn;
    116116        ConstantNode *constant;
    117         LabelNode *label;
    118117        InitializerNode *in;
    119         bool flag;
    120118}
    121119
     
    136134%type<en> argument_expression_list              argument_expression                     for_control_expression          assignment_opt
    137135%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
    142136
    143137// statements
     
    338332        | zero_one
    339333                { $$ = new VarRefNode( $1 ); }
     334        | constant
     335                { $$ = $1; }
     336        | string_literal_list
     337                { $$ = $1; }
    340338        | '(' comma_expression ')'
    341339                { $$ = $2; }
     
    380378        | assignment_expression
    381379        | no_attr_identifier ':' assignment_expression
    382                 { $$ = $3->set_argName( $1 ); }
     380                { $$ = $3->set_asArgName( $1 ); }
    383381                // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient
    384382                // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used
    385383                // with an appropriate semantic check.
    386384        | '[' push assignment_expression pop ']' ':' assignment_expression
    387                 { $$ = $7->set_argName( $3 ); }
     385                { $$ = $7->set_asArgName( $3 ); }
    388386        | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
    389                 { $$ = $9->set_argName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
     387                { $$ = $9->set_asArgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
    390388        ;
    391389
     
    410408unary_expression:
    411409        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; }
    418410        | ICR unary_expression
    419411                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); }
     
    643635                // requires its own scope
    644636          push push
    645           local_label_declaration_opt                                           // GCC, local labels
     637          label_declaration_opt                                                         // GCC, local labels
    646638          block_item_list pop '}'                                                       // C99, intermix declarations and statements
    647639                { $$ = new CompoundStmtNode( $5 ); }
     
    762754
    763755fall_through:                                                                                   // CFA
    764         FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru ); }
    765         | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru ); }
     756        FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
     757        | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
    766758        ;
    767759
     
    791783        | CONTINUE ';'
    792784                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    793                 { $$ = new StatementNode( StatementNode::Continue ); }
     785                { $$ = new StatementNode( StatementNode::Continue, 0, 0 ); }
    794786        | CONTINUE no_attr_identifier ';'                                       // CFA, multi-level continue
    795787                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     
    798790        | BREAK ';'
    799791                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    800                 { $$ = new StatementNode( StatementNode::Break ); }
     792                { $$ = new StatementNode( StatementNode::Break, 0, 0 ); }
    801793        | BREAK no_attr_identifier ';'                                          // CFA, multi-level exit
    802794                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     
    808800                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    809801        | THROW ';'
    810                 { $$ = new StatementNode( StatementNode::Throw ); }
     802                { $$ = new StatementNode( StatementNode::Throw, 0, 0 ); }
    811803        ;
    812804
     
    871863
    872864asm_statement:
    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 
    885 asm_volatile_opt:                                                                               // GCC
    886         // empty
    887                 { $$ = false; }
    888         | VOLATILE
    889                 { $$ = true; }
     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 ); }
    890873        ;
    891874
    892875asm_operands_opt:                                                                               // GCC
    893876        // empty
    894                 { $$ = 0; }                                                                             // use default argument
    895877        | asm_operands_list
    896878        ;
     
    899881        asm_operand
    900882        | asm_operands_list ',' asm_operand
    901                 { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    902883        ;
    903884
    904885asm_operand:                                                                                    // GCC
    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 
    911 asm_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 
    920 label_list:
    921         no_attr_identifier
    922                 { $$ = new LabelNode(); $$->append_label( $1 ); }
    923         | label_list ',' no_attr_identifier
    924                 { $$ = $1; $1->append_label( $3 ); }
     886        STRINGliteral '(' constant_expression ')'       {}
     887        ;
     888
     889asm_clobbers_list:                                                                              // GCC
     890        STRINGliteral                                                           {}
     891        | asm_clobbers_list ',' STRINGliteral
    925892        ;
    926893
     
    951918        ;
    952919
    953 local_label_declaration_opt:                                                    // GCC, local label
     920label_declaration_opt:                                                                  // GCC, local label
    954921        // empty
    955         | local_label_declaration_list
    956         ;
    957 
    958 local_label_declaration_list:                                                   // GCC, local label
    959         LABEL local_label_list ';'
    960         | local_label_declaration_list LABEL local_label_list ';'
    961         ;
    962 
    963 local_label_list:                                                                               // GCC, local label
    964         no_attr_identifier_or_type_name                         {}
    965         | local_label_list ',' no_attr_identifier_or_type_name {}
     922        | label_declaration_list
     923        ;
     924
     925label_declaration_list:                                                                 // GCC, local label
     926        LABEL label_list ';'
     927        | label_declaration_list LABEL label_list ';'
     928        ;
     929
     930label_list:                                                                                             // GCC, local label
     931        no_attr_identifier_or_type_name                 {}
     932        | label_list ',' no_attr_identifier_or_type_name {}
    966933        ;
    967934
     
    16931660
    16941661designator:
    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 ) ); }
     1662        '.' no_attr_identifier_or_type_name                                     // C99, field name
     1663                { $$ = new VarRefNode( $2 ); }
    17001664        | '[' push assignment_expression pop ']'                        // C99, single array element
    17011665                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
    1702                 { $$ = new DesignatorNode( $3, true ); }
     1666                { $$ = $3; }
    17031667        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    1704                 { $$ = new DesignatorNode( $3, true ); }
     1668                { $$ = $3; }
    17051669        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1706                 { $$ = new DesignatorNode( new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ), true ); }
     1670                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ); }
    17071671        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    1708                 { $$ = new DesignatorNode( $4 ); }
     1672                { $$ = $4; }
    17091673        ;
    17101674
Note: See TracChangeset for help on using the changeset viewer.