Ignore:
Timestamp:
Sep 28, 2015, 6:25:43 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:
097e2b0, 1cbca6e
Parents:
20e409e
Message:

add preprocessor flag -DCFORALL=1, add syntax for constructor/destructor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r20e409e r02e5ab6  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 11 16:01:49 2015
    13 // Update Count     : 1350
     12// Last Modified On : Mon Sep 28 18:18:32 2015
     13// Update Count     : 1402
    1414//
    1515
     
    8181%token ATTRIBUTE EXTENSION                                                              // GCC
    8282%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    83 %token CHOOSE FALLTHRU TRY CATCH FINALLY THROW                  // CFA
     83%token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT        // CFA
    8484%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    8585%token ALIGNAS ALIGNOF ATOMIC GENERIC NORETURN STATICASSERT THREADLOCAL // C11
     
    120120}
    121121
    122 %type<tok> zero_one  identifier  no_attr_identifier  no_01_identifier
     122%type<tok> identifier  no_01_identifier  no_attr_identifier no_attr_identifier_01  zero_one
    123123%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  no_01_identifier_or_type_name
    124124%type<constant> string_literal_list
     
    143143// statements
    144144%type<sn> labeled_statement                             compound_statement                      expression_statement            selection_statement
    145 %type<sn> iteration_statement                   jump_statement                          exception_statement                     asm_statement
     145%type<sn> iteration_statement                   jump_statement                          exception_statement                     asm_statement                   ctor_dtor
    146146%type<sn> fall_through_opt                              fall_through
    147147%type<sn> statement                                             statement_list
     
    319319no_attr_identifier:
    320320        IDENTIFIER
     321        ;
     322
     323no_attr_identifier_01:
     324        IDENTIFIER
     325        | zero_one
    321326        ;
    322327
     
    445450                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), $2 ); }
    446451        | ALIGNOF '(' type_name_no_function ')'                         // GCC, type alignment
    447                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), new TypeValueNode( $3 )); }
     452                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::AlignOf ), new TypeValueNode( $3 ) ); }
    448453        | ANDAND no_attr_identifier                                                     // GCC, address of label
    449                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LabelAddress ), new VarRefNode( $2, true )); }
     454                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::LabelAddress ), new VarRefNode( $2, true ) ); }
    450455        ;
    451456
     
    627632        | exception_statement
    628633        | asm_statement
     634        | ctor_dtor
    629635        ;
    630636
     
    805811        | RETURN comma_expression_opt ';'
    806812                { $$ = new StatementNode( StatementNode::Return, $2, 0 ); }
    807         | THROW assignment_expression ';'
     813        | THROW assignment_expression_opt ';'
    808814                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    809         | THROW ';'
    810                 { $$ = new StatementNode( StatementNode::Throw ); }
     815//      | THROW ';'
     816//              { $$ = new StatementNode( StatementNode::Throw ); }
     817        | THROWRESUME assignment_expression_opt ';'
     818                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
     819        | THROWRESUME assignment_expression_opt AT assignment_expression ';'
     820                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
     821//      | THROWRESUME ';'
     822//              { $$ = new StatementNode( StatementNode::Throw ); }
    811823        ;
    812824
     
    831843        | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
    832844                { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true ) ); }
     845        | CATCHRESUME '(' ELLIPSIS ')' compound_statement
     846                { $$ = StatementNode::newCatchStmt( 0, $5, true ); }
     847        | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
     848                { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true ) ); }
    833849        ;
    834850
     
    837853                { $$ = StatementNode::newCatchStmt( $5, $8 ); }
    838854        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
     855                { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
     856        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
     857                { $$ = StatementNode::newCatchStmt( $5, $8 ); }
     858        | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    839859                { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9 ) ); }
    840860        ;
     
    923943        | label_list ',' no_attr_identifier
    924944                { $$ = $1; $1->append_label( $3 ); }
     945        ;
     946
     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                }
    925960        ;
    926961
     
    16931728
    16941729designator:
     1730        // lexer ambiguity: designator ".0" is floating-point constant or designator for name 0
    16951731        // only ".0" and ".1" allowed => semantic check
    16961732        FLOATINGconstant
Note: See TracChangeset for help on using the changeset viewer.