Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rcbce272 r8b47e50  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Aug  4 13:33:00 2017
    13 // Update Count     : 2475
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jul 12 18:23:36 2017
     13// Update Count     : 2426
    1414//
    1515
     
    118118%token RESTRICT                                                                                 // C99
    119119%token ATOMIC                                                                                   // C11
    120 %token FORALL LVALUE MUTEX VIRTUAL                                              // CFA
    121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
     120%token FORALL LVALUE MUTEX                                                              // CFA
     121%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T
     122%token VALIST                                                                                   // GCC
    122123%token BOOL COMPLEX IMAGINARY                                                   // C99
    123 %token ZERO_T ONE_T                                                                             // CFA
    124 %token VALIST                                                                                   // GCC
    125124%token TYPEOF LABEL                                                                             // GCC
    126125%token ENUM STRUCT UNION
     
    142141// converted into the tuple index (.)(1). e.g., 3.x
    143142%token<tok>     REALDECIMALconstant     REALFRACTIONconstant    FLOATINGconstant
     143%token<tok> ZERO                                ONE                                             // CFA
    144144
    145145// multi-character operators
     
    151151%token ELLIPSIS                                                                                 // ...
    152152
    153 %token EXPassign        MULTassign      DIVassign       MODassign       // \=   *=      /=      %=
     153%token MULTassign       DIVassign       MODassign                               // *=   /=      %=/
    154154%token PLUSassign       MINUSassign                                                     // +=   -=
    155155%token LSassign         RSassign                                                        // <<=  >>=
     
    158158%token ATassign                                                                                 // @=
    159159
    160 %type<tok> identifier  no_attr_identifier
     160%type<tok> identifier  no_attr_identifier  zero_one
    161161%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
    162162%type<constant> string_literal
     
    168168%type<op> ptrref_operator                               unary_operator                          assignment_operator
    169169%type<en> primary_expression                    postfix_expression                      unary_expression
    170 %type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
    171 %type<en> shift_expression                              relational_expression           equality_expression
    172 %type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
    173 %type<en> logical_AND_expression                logical_OR_expression
    174 %type<en> conditional_expression                constant_expression                     assignment_expression           assignment_expression_opt
     170%type<en> cast_expression                               multiplicative_expression       additive_expression                     shift_expression
     171%type<en> relational_expression                 equality_expression                     AND_expression                          exclusive_OR_expression
     172%type<en> inclusive_OR_expression               logical_AND_expression          logical_OR_expression           conditional_expression
     173%type<en> constant_expression                   assignment_expression           assignment_expression_opt
    175174%type<en> comma_expression                              comma_expression_opt
    176 %type<en> argument_expression_list              argument_expression                     default_initialize_opt
     175%type<en> argument_expression_list              argument_expression                     assignment_opt
    177176%type<fctl> for_control_expression
    178177%type<en> subrange
     
    182181%type<en> asm_clobbers_list_opt
    183182%type<flag> asm_volatile_opt
    184 %type<en> handler_predicate_opt
    185183
    186184// statements
     
    360358        ;
    361359
     360zero_one:                                                                                               // CFA
     361        ZERO
     362        | ONE
     363        ;
     364
    362365string_literal:
    363366        string_literal_list                                                     { $$ = build_constantStr( *$1 ); }
     
    379382        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
    380383                { $$ = new ExpressionNode( build_varref( $1 ) ); }
     384        | zero_one
     385                { $$ = new ExpressionNode( build_constantZeroOne( *$1 ) ); }
    381386        | tuple
    382387        | '(' comma_expression ')'
     
    478483                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
    479484                }
     485        | zero_one fraction_constants
     486                {
     487                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_constantZeroOne( *$1 ), $2 ) );
     488                }
    480489        ;
    481490
     
    528537        | ALIGNOF unary_expression                                                      // GCC, variable alignment
    529538                { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); }
    530         | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
     539        | ALIGNOF '(' type_no_function ')'                              // GCC, type alignment
    531540                { $$ = new ExpressionNode( build_alignOftype( $3 ) ); }
    532541        | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
     
    560569        | '(' type_no_function ')' cast_expression
    561570                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    562                 // VIRTUAL cannot be opt because of look ahead issues
    563         | '(' VIRTUAL ')' cast_expression
    564                 { $$ = new ExpressionNode( build_virtual_cast( nullptr, $4 ) ); }
    565         | '(' VIRTUAL type_no_function ')' cast_expression
    566                 { $$ = new ExpressionNode( build_virtual_cast( $3, $5 ) ); }
    567571//      | '(' type_no_function ')' tuple
    568572//              { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    569573        ;
    570574
    571 exponential_expression:
     575multiplicative_expression:
    572576        cast_expression
    573         | exponential_expression '\\' cast_expression
    574                 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); }
    575         ;
    576 
    577 multiplicative_expression:
    578         exponential_expression
    579         | multiplicative_expression '*' exponential_expression
     577        | multiplicative_expression '*' cast_expression
    580578                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    581         | multiplicative_expression '/' exponential_expression
     579        | multiplicative_expression '/' cast_expression
    582580                { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    583         | multiplicative_expression '%' exponential_expression
     581        | multiplicative_expression '%' cast_expression
    584582                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    585583        ;
     
    680678        '='                                                                                     { $$ = OperKinds::Assign; }
    681679        | ATassign                                                                      { $$ = OperKinds::AtAssn; }
    682         | EXPassign                                                                     { $$ = OperKinds::ExpAssn; }
    683680        | MULTassign                                                            { $$ = OperKinds::MulAssn; }
    684681        | DIVassign                                                                     { $$ = OperKinds::DivAssn; }
     
    942939
    943940with_statement:
    944         WITH '(' tuple_expression_list ')' compound_statement
     941        WITH identifier_list compound_statement
    945942                { $$ = (StatementNode *)0; }                                    // FIX ME
    946943        ;
     
    969966
    970967handler_clause:
    971         handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
    972                 { $$ = new StatementNode( build_catch( $1, $5, $7, $9 ) ); }
    973         | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
    974                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, $8, $10 ) ) ); }
    975         ;
    976 
    977 handler_predicate_opt:
    978         //empty
    979                 { $$ = nullptr; }
    980         | ';' conditional_expression
    981                 { $$ = $2; }
     968        // TEMPORARY, TEST EXCEPTIONS
     969        handler_key '(' push push INTEGERconstant pop ')' compound_statement pop
     970                { $$ = new StatementNode( build_catch( $1, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); }
     971        | handler_clause handler_key '(' push push INTEGERconstant pop ')' compound_statement pop
     972                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
     973
     974        | handler_key '(' push push exception_declaration pop ')' compound_statement pop
     975                { $$ = new StatementNode( build_catch( $1, $5, nullptr, $8 ) ); }
     976        | handler_clause handler_key '(' push push exception_declaration pop ')' compound_statement pop
     977                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $9 ) ) ); }
    982978        ;
    983979
     
    15061502        | IMAGINARY                                                                                     // C99
    15071503                { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); }
     1504        | VALIST                                                                                        // GCC, __builtin_va_list
     1505                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    15081506        | ZERO_T
    15091507                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
    15101508        | ONE_T
    15111509                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); }
    1512         | VALIST                                                                                        // GCC, __builtin_va_list
    1513                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    15141510        ;
    15151511
     
    18491845cfa_parameter_declaration:                                                              // CFA, new & old style parameter declaration
    18501846        parameter_declaration
    1851         | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt
     1847        | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt
    18521848                { $$ = $1->addName( $2 ); }
    1853         | cfa_abstract_tuple identifier_or_type_name default_initialize_opt
     1849        | cfa_abstract_tuple identifier_or_type_name assignment_opt
    18541850                // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator).
    18551851                { $$ = $1->addName( $2 ); }
    1856         | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt
     1852        | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt
    18571853                { $$ = $2->addName( $3 )->addQualifiers( $1 ); }
    18581854        | cfa_function_specifier
     
    18711867parameter_declaration:
    18721868                // No SUE declaration in parameter list.
    1873         declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt
     1869        declaration_specifier_nobody identifier_parameter_declarator assignment_opt
    18741870                {
    18751871                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    18761872                        $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
    18771873                }
    1878         | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt
     1874        | declaration_specifier_nobody type_parameter_redeclarator assignment_opt
    18791875                {
    18801876                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    18841880
    18851881abstract_parameter_declaration:
    1886         declaration_specifier_nobody default_initialize_opt
     1882        declaration_specifier_nobody assignment_opt
    18871883                { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); }
    1888         | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt
     1884        | declaration_specifier_nobody abstract_parameter_declarator assignment_opt
    18891885                { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); }
    18901886        ;
     
    19301926        | '=' initializer
    19311927                { $$ = $2; }
    1932         | '=' VOID
    1933                 { $$ = nullptr; }
    19341928        | ATassign initializer
    19351929                { $$ = $2->set_maybeConstructed( false ); }
     
    22282222        // empty
    22292223                { $$ = (StatementNode *)0; }                                    // FIX ME
    2230         | WITH '(' tuple_expression_list ')'
     2224        | WITH identifier_list
    22312225                { $$ = (StatementNode *)0; }                                    // FIX ME
    22322226        ;
     
    30513045        ;
    30523046
    3053 default_initialize_opt:
     3047assignment_opt:
    30543048        // empty
    30553049                { $$ = nullptr; }
Note: See TracChangeset for help on using the changeset viewer.