Ignore:
Timestamp:
Aug 11, 2015, 4:16:03 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, string, with_gc
Children:
a3a17ba
Parents:
99f4165
Message:

move constant/string to unary_expression, temporarily separate asm and local label, introduce DesignatorNode?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r99f4165 r51b1202  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 30 15:29:19 2015
    13 // Update Count     : 1327
     12// Last Modified On : Tue Aug 11 16:01:49 2015
     13// Update Count     : 1350
    1414//
    1515
     
    338338        | zero_one
    339339                { $$ = new VarRefNode( $1 ); }
    340         | constant
    341                 { $$ = $1; }
    342         | string_literal_list
    343                 { $$ = $1; }
    344340        | '(' comma_expression ')'
    345341                { $$ = $2; }
     
    414410unary_expression:
    415411        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; }
    416418        | ICR unary_expression
    417419                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Incr ), $2 ); }
     
    641643                // requires its own scope
    642644          push push
    643           label_declaration_opt                                                         // GCC, local labels
     645          local_label_declaration_opt                                           // GCC, local labels
    644646          block_item_list pop '}'                                                       // C99, intermix declarations and statements
    645647                { $$ = new CompoundStmtNode( $5 ); }
     
    949951        ;
    950952
    951 label_declaration_opt:                                                                  // GCC, local label
     953local_label_declaration_opt:                                                    // GCC, local label
    952954        // empty
    953         | label_declaration_list
    954         ;
    955 
    956 label_declaration_list:                                                                 // GCC, local label
    957         LABEL label_list ';'
    958         | label_declaration_list LABEL label_list ';'
    959         ;
    960 
    961 label_list:                                                                                             // GCC, local label
     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
    962964        no_attr_identifier_or_type_name                         {}
    963         | label_list ',' no_attr_identifier_or_type_name {}
     965        | local_label_list ',' no_attr_identifier_or_type_name {}
    964966        ;
    965967
     
    16911693
    16921694designator:
    1693         '.' no_attr_identifier_or_type_name                                     // C99, field name
    1694                 { $$ = 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 ) ); }
    16951700        | '[' push assignment_expression pop ']'                        // C99, single array element
    16961701                // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple.
    1697                 { $$ = $3; }
     1702                { $$ = new DesignatorNode( $3, true ); }
    16981703        | '[' push subrange pop ']'                                                     // CFA, multiple array elements
    1699                 { $$ = $3; }
     1704                { $$ = new DesignatorNode( $3, true ); }
    17001705        | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements
    1701                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ); }
     1706                { $$ = new DesignatorNode( new CompositeExprNode( new OperatorNode( OperatorNode::Range ), $3, $5 ), true ); }
    17021707        | '.' '[' push field_list pop ']'                                       // CFA, tuple field selector
    1703                 { $$ = $4; }
     1708                { $$ = new DesignatorNode( $4 ); }
    17041709        ;
    17051710
Note: See TracChangeset for help on using the changeset viewer.