Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r097e2b0 r02e5ab6  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Oct  8 17:17:54 2015
    13 // Update Count     : 1473
     12// Last Modified On : Mon Sep 28 18:18:32 2015
     13// Update Count     : 1402
    1414//
    1515
     
    104104%token ANDassign        ERassign        ORassign                                // &=   ^=      |=
    105105
    106 %token ATassign                                                                                 // @=
    107 
    108106// Types declaration
    109107%union
     
    122120}
    123121
    124 %type<tok> identifier  no_01_identifier  no_attr_identifier zero_one
     122%type<tok> identifier  no_01_identifier  no_attr_identifier no_attr_identifier_01  zero_one
    125123%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  no_01_identifier_or_type_name
    126124%type<constant> string_literal_list
     
    145143// statements
    146144%type<sn> labeled_statement                             compound_statement                      expression_statement            selection_statement
    147 %type<sn> iteration_statement                   jump_statement                          exception_statement                     asm_statement
     145%type<sn> iteration_statement                   jump_statement                          exception_statement                     asm_statement                   ctor_dtor
    148146%type<sn> fall_through_opt                              fall_through
    149147%type<sn> statement                                             statement_list
     
    319317        ;
    320318
    321 // no zero_one because ambiguity with 0.0 : double constant or field selection
    322319no_attr_identifier:
    323320        IDENTIFIER
     321        ;
     322
     323no_attr_identifier_01:
     324        IDENTIFIER
     325        | zero_one
    324326        ;
    325327
     
    367369        | postfix_expression DECR
    368370                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::DecrPost ), $1 ); }
     371                // GCC has priority: cast_expression
    369372        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
    370373                { $$ = 0; }
    371         | postfix_expression '{' argument_expression_list '}' // CFA
    372                 {
    373                         Token fn; fn.str = new std::string( "?{}" ); // location undefined
    374                         $$ = new CompositeExprNode( new VarRefNode( fn ), (ExpressionNode *)( $1 )->set_link( $3 ) );
    375                 }
    376374        ;
    377375
     
    634632        | exception_statement
    635633        | asm_statement
    636         | '^' postfix_expression '{' argument_expression_list '}' ';' // CFA
    637                 {
    638                         Token fn; fn.str = new std::string( "^?{}" ); // location undefined
    639                         $$ = new StatementNode( StatementNode::Exp, new CompositeExprNode( new VarRefNode( fn ),
    640                                 (ExpressionNode *)(new CompositeExprNode( new OperatorNode( OperatorNode::AddressOf ), $2 ))->set_link( $4 ) ), 0 );
    641                 }
     634        | ctor_dtor
    642635        ;
    643636
     
    952945        ;
    953946
     947ctor_dtor:                                                                                              // CFA, constructor/destructor
     948        no_attr_identifier_01 '{' argument_expression_list '}' ';'
     949                {
     950                        Token fn; fn.str = new std::string( "?{}" ); fn.loc = $1.loc;
     951                        $$ = new StatementNode( StatementNode::Exp, new CompositeExprNode( new VarRefNode( fn ),
     952                                   (ExpressionNode *)((new CompositeExprNode( new OperatorNode( OperatorNode::AddressOf ), new VarRefNode( $1 ) ))->set_link( $3 )) ), 0 );
     953                }
     954        | '^' no_attr_identifier_01 '{' '}' ';'
     955                {
     956                        Token fn; fn.str = new std::string( "^?{}" ); fn.loc = $2.loc;
     957                        $$ = new StatementNode( StatementNode::Exp, new CompositeExprNode( new VarRefNode( fn ),
     958                                   new CompositeExprNode( new OperatorNode( OperatorNode::AddressOf ), new VarRefNode( $2 ) ) ), 0 );
     959                }
     960        ;
     961
    954962//******************************* DECLARATIONS *********************************
    955963
     
    16811689        | '=' initializer
    16821690                { $$ = $2; }
    1683         | ATassign initializer
    1684                 { $$ = $2; }
    16851691        ;
    16861692
     
    16911697
    16921698initializer_list:
    1693         // empty
    1694                 { $$ = 0; }
    1695         | initializer
     1699        initializer
    16961700        | designation initializer                                       { $$ = $2->set_designators( $1 ); }
    16971701        | initializer_list ',' initializer                      { $$ = (InitializerNode *)( $1->set_link( $3 ) ); }
Note: See TracChangeset for help on using the changeset viewer.