Ignore:
Timestamp:
Jul 15, 2017, 8:35:37 AM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
bac5158
Parents:
24fc196
Message:

add exponential operator and syntax for catch predicate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r24fc196 r994d080  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 13 14:38:54 2017
    13 // Update Count     : 2431
     12// Last Modified On : Sat Jul 15 08:17:48 2017
     13// Update Count     : 2450
    1414//
    1515
     
    168168%type<op> ptrref_operator                               unary_operator                          assignment_operator
    169169%type<en> primary_expression                    postfix_expression                      unary_expression
    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
     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
    174175%type<en> comma_expression                              comma_expression_opt
    175 %type<en> argument_expression_list              argument_expression                     assignment_opt
     176%type<en> argument_expression_list              argument_expression                     default_initialize_opt
    176177%type<fctl> for_control_expression
    177178%type<en> subrange
     
    573574        ;
    574575
     576exponential_expression:
     577        cast_expression
     578        | exponential_expression '\\' cast_expression
     579                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
     580        ;
     581
    575582multiplicative_expression:
    576         cast_expression
    577         | multiplicative_expression '*' cast_expression
     583        exponential_expression
     584        | multiplicative_expression '*' exponential_expression
    578585                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    579         | multiplicative_expression '/' cast_expression
     586        | multiplicative_expression '/' exponential_expression
    580587                { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    581         | multiplicative_expression '%' cast_expression
     588        | multiplicative_expression '%' exponential_expression
    582589                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    583590        ;
     
    972979                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
    973980
    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 ) ) ); }
     981        | handler_key '(' push push exception_declaration handler_predicate_opt pop ')' compound_statement pop
     982                { $$ = new StatementNode( build_catch( $1, $5, nullptr, $9 ) ); }
     983        | handler_clause handler_key '(' push push exception_declaration handler_predicate_opt pop ')' compound_statement pop
     984                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $10 ) ) ); }
     985        ;
     986
     987handler_predicate_opt:
     988        //empty
     989        | ':' conditional_expression
    978990        ;
    979991
     
    18451857cfa_parameter_declaration:                                                              // CFA, new & old style parameter declaration
    18461858        parameter_declaration
    1847         | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt
     1859        | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt
    18481860                { $$ = $1->addName( $2 ); }
    1849         | cfa_abstract_tuple identifier_or_type_name assignment_opt
     1861        | cfa_abstract_tuple identifier_or_type_name default_initialize_opt
    18501862                // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator).
    18511863                { $$ = $1->addName( $2 ); }
    1852         | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt
     1864        | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt
    18531865                { $$ = $2->addName( $3 )->addQualifiers( $1 ); }
    18541866        | cfa_function_specifier
     
    18671879parameter_declaration:
    18681880                // No SUE declaration in parameter list.
    1869         declaration_specifier_nobody identifier_parameter_declarator assignment_opt
     1881        declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt
    18701882                {
    18711883                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    18721884                        $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
    18731885                }
    1874         | declaration_specifier_nobody type_parameter_redeclarator assignment_opt
     1886        | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt
    18751887                {
    18761888                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    18801892
    18811893abstract_parameter_declaration:
    1882         declaration_specifier_nobody assignment_opt
     1894        declaration_specifier_nobody default_initialize_opt
    18831895                { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); }
    1884         | declaration_specifier_nobody abstract_parameter_declarator assignment_opt
     1896        | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt
    18851897                { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); }
    18861898        ;
     
    30453057        ;
    30463058
    3047 assignment_opt:
     3059default_initialize_opt:
    30483060        // empty
    30493061                { $$ = nullptr; }
Note: See TracChangeset for help on using the changeset viewer.