Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r3a2128f r8780e30  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Nov 29 11:35:52 2016
    13 // Update Count     : 2069
     12// Last Modified On : Wed Oct 26 17:35:53 2016
     13// Update Count     : 2066
    1414//
    1515
     
    7878%token RESTRICT                                                                                 // C99
    7979%token FORALL LVALUE                                                                    // CFA
    80 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T
     80%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    8181%token VALIST                                                                                   // GCC
    8282%token BOOL COMPLEX IMAGINARY                                                   // C99
     
    199199
    200200%type<decl> field_declaration field_declaration_list field_declarator field_declaring_list
    201 %type<en> field field_list
    202 %type<tok> field_name
     201%type<en> field field_list field_name fraction_constants
    203202
    204203%type<decl> external_function_definition function_definition function_array function_declarator function_no_ptr function_ptr
     
    384383                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    385384        | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector
     385                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    386386        | postfix_expression REALFRACTIONconstant                       // CFA, tuple index
     387                { $$ = new ExpressionNode( build_fieldSel( $1, build_field_name_REALFRACTIONconstant( *$2 ) ) ); }
    387388        | postfix_expression ARROW no_attr_identifier
    388389                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    389390        | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector
     391                        { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    390392        | postfix_expression ICR
    391393                { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }
     
    421423field:                                                                                                  // CFA, tuple field selector
    422424        field_name
    423                 { $$ = new ExpressionNode( build_varref( $1 ) ); }
    424425        | REALDECIMALconstant field
    425                 { $$ = new ExpressionNode( build_fieldSel( $2, build_varref( $1 ) ) ); }
     426                { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *$1 ) ), maybeMoveBuild<Expression>( $2 ) ) ); }
    426427        | REALDECIMALconstant '[' push field_list pop ']'
    427                 { $$ = new ExpressionNode( build_fieldSel( $4, build_varref( $1 ) ) ); }
     428                { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_REALDECIMALconstant( *$1 ) ), build_tuple( $4 ) ) ); }
    428429        | field_name '.' field
    429                 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); }
     430                { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); }
    430431        | field_name '.' '[' push field_list pop ']'
    431                 { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); }
     432                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $5 ) ) ); }
    432433        | field_name ARROW field
    433                 { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); }
     434                { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild<Expression>( $3 ) ) ); }
    434435        | field_name ARROW '[' push field_list pop ']'
    435                 { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); }
     436                { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $5 ) ) ); }
    436437        ;
    437438
    438439field_name:
    439440        INTEGERconstant fraction_constants
    440                 { $$ = $1; }
     441                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantInteger( *$1 ), $2 ) ); }
    441442        | FLOATINGconstant fraction_constants
    442                 { $$ = $1; }
     443                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    443444        | no_attr_identifier fraction_constants
    444                 { $$ = $1; }
     445                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); }
    445446        ;
    446447
    447448fraction_constants:
    448449        // empty
     450                { $$ = nullptr; }
    449451        | fraction_constants REALFRACTIONconstant
     452                {
     453                        Expression * constant = build_field_name_REALFRACTIONconstant( *$2 );
     454                        $$ = $1 != nullptr ? new ExpressionNode( build_fieldSel( $1,  constant ) ) : new ExpressionNode( constant );
     455                }
    450456        ;
    451457
     
    708714        | '{'
    709715                // Two scopes are necessary because the block itself has a scope, but every declaration within the block also
    710                 // requires its own scope.
     716                // requires its own scope
    711717          push push
    712718          local_label_declaration_opt                                           // GCC, local labels
     
    14041410        | VALIST                                                                                        // GCC, __builtin_va_list
    14051411                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    1406         | ZERO_T
    1407                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); }
    1408         | ONE_T
    1409                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Char ); }
    14101412        ;
    14111413
Note: See TracChangeset for help on using the changeset viewer.