Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r1efa1e1 r9bd6105  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 23 21:08:08 2017
    13 // Update Count     : 2704
     12// Last Modified On : Sat Aug 26 17:50:19 2017
     13// Update Count     : 2712
    1414//
    1515
     
    9797        DeclarationNode::TypeClass tclass;
    9898        StatementNode * sn;
     99        WaitForStmt * wfs;
    99100        ConstantExpr * constant;
    100101        IfCtl * ifctl;
     
    119120%token RESTRICT                                                                                 // C99
    120121%token ATOMIC                                                                                   // C11
    121 %token FORALL MUTEX VIRTUAL                                             // CFA
     122%token FORALL MUTEX VIRTUAL                                                             // CFA
    122123%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    123124%token BOOL COMPLEX IMAGINARY                                                   // C99
     
    189190
    190191// statements
    191 %type<sn> labeled_statement                             compound_statement                      expression_statement            selection_statement
    192 %type<sn> iteration_statement                   jump_statement
    193 %type<sn> with_statement                                exception_statement                     asm_statement
    194 %type<sn> when_clause_opt                               waitfor_statement                       waitfor_clause                          waitfor                         timeout
    195 %type<sn> fall_through_opt                              fall_through
    196 %type<sn> statement                                             statement_list
    197 %type<sn> block_item_list                               block_item
    198 %type<sn> with_clause_opt
     192%type<sn> statement                                             labeled_statement                       compound_statement
     193%type<sn> statement_decl                                statement_decl_list                     statement_list_nodecl
     194%type<sn> selection_statement
     195%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    199196%type<en> case_value
    200197%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    201 %type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    202 %type<sn> handler_clause                                finally_clause
     198%type<sn> fall_through                                  fall_through_opt
     199%type<sn> iteration_statement                   jump_statement
     200%type<sn> expression_statement                  asm_statement
     201%type<sn> with_statement                                with_clause_opt
     202%type<sn> exception_statement                   handler_clause                          finally_clause
    203203%type<catch_kind> handler_key
     204%type<en> when_clause                                   when_clause_opt                         waitfor                                         timeout
     205%type<sn> waitfor_statement
     206%type<wfs> waitfor_clause
    204207
    205208// declarations
     
    773776          push push
    774777          local_label_declaration_opt                                           // GCC, local labels
    775           block_item_list                                                                       // C99, intermix declarations and statements
     778          statement_decl_list                                                           // C99, intermix declarations and statements
    776779          pop '}'
    777780                { $$ = new StatementNode( build_compound( $5 ) ); }
    778781        ;
    779782
    780 block_item_list:                                                                                // C99
    781         block_item
    782         | block_item_list push block_item
     783statement_decl_list:                                                                    // C99
     784        statement_decl
     785        | statement_decl_list push statement_decl
    783786                { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } }
    784787        ;
    785788
    786 block_item:
     789statement_decl:
    787790        declaration                                                                                     // CFA, new & old style declarations
    788791                { $$ = new StatementNode( $1 ); }
     
    802805        ;
    803806
    804 statement_list:
     807statement_list_nodecl:
    805808        statement
    806         | statement_list statement
     809        | statement_list_nodecl statement
    807810                { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } }
    808811        ;
     
    814817
    815818selection_statement:
    816         IF '(' push if_control_expression ')' statement                         %prec THEN
     819        IF '(' push if_control_expression ')' statement         %prec THEN
    817820                // explicitly deal with the shift/reduce conflict on if/else
    818821                { $$ = new StatementNode( build_if( $4, $6, nullptr ) ); }
     
    889892
    890893switch_clause_list:                                                                             // CFA
    891         case_label_list statement_list
     894        case_label_list statement_list_nodecl
    892895                { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); }
    893         | switch_clause_list case_label_list statement_list
     896        | switch_clause_list case_label_list statement_list_nodecl
    894897                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); }
    895898        ;
     
    904907        case_label_list fall_through
    905908                { $$ = $1->append_last_case( $2 ); }
    906         | case_label_list statement_list fall_through_opt
     909        | case_label_list statement_list_nodecl fall_through_opt
    907910                { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); }
    908911        | choose_clause_list case_label_list fall_through
    909912                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); }
    910         | choose_clause_list case_label_list statement_list fall_through_opt
     913        | choose_clause_list case_label_list statement_list_nodecl fall_through_opt
    911914                { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); }
    912915        ;
     
    977980        ;
    978981
     982when_clause:
     983        WHEN '(' comma_expression ')'
     984                { $$ = $3; }
     985        ;
     986
    979987when_clause_opt:
    980988        // empty
    981                 { $$ = nullptr; }                                                               // FIX ME
    982         | WHEN '(' comma_expression ')'
    983                 { $$ = nullptr; }                                                               // FIX ME
     989                { $$ = nullptr; }
     990        | when_clause
    984991        ;
    985992
    986993waitfor:
    987994        WAITFOR '(' identifier ')'
    988                 { $$ = nullptr; }                                                               // FIX ME
     995                {
     996                        $$ = new ExpressionNode( new NameExpr( *$3 ) );
     997                        delete $3;
     998                }
    989999        | WAITFOR '(' identifier ',' argument_expression_list ')'
    990                 { $$ = nullptr; }                                                               // FIX ME
     1000                {
     1001                        $$ = new ExpressionNode( new NameExpr( *$3 ) );
     1002                        $$->set_last( $5 );
     1003                        delete $3;
     1004                }
    9911005        ;
    9921006
    9931007timeout:
    9941008        TIMEOUT '(' comma_expression ')'
    995                 { $$ = nullptr; }                                                               // FIX ME
     1009                { $$ = $3; }
    9961010        ;
    9971011
    9981012waitfor_clause:
    999         when_clause_opt waitfor statement %prec THEN
    1000                 { $$ = nullptr; }                                                               // FIX ME
     1013        when_clause_opt waitfor statement                                       %prec THEN
     1014                { $$ = build_waitfor( $2, $3, $1 ); }
    10011015        | when_clause_opt waitfor statement WOR waitfor_clause
    1002                 { $$ = nullptr; }                                                               // FIX ME
    1003         | when_clause_opt timeout statement %prec THEN
    1004                 { $$ = nullptr; }                                                               // FIX ME
     1016                { $$ = build_waitfor( $2, $3, $1, $5 ); }
     1017        | when_clause_opt timeout statement                                     %prec THEN
     1018                { $$ = build_waitfor_timeout( $2, $3, $1 ); }
    10051019        | when_clause_opt ELSE statement
    1006                 { $$ = nullptr; }                                                               // FIX ME
    1007         | when_clause_opt timeout statement WOR when_clause_opt ELSE statement
    1008                 { $$ = nullptr; }                                                               // FIX ME
     1020                { $$ = build_waitfor_timeout( nullptr, $3, $1 ); }
     1021                // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless)
     1022        | when_clause_opt timeout statement WOR when_clause ELSE statement
     1023                { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); }
    10091024        ;
    10101025
    10111026waitfor_statement:
    1012         when_clause_opt waitfor statement %prec THEN
    1013                 { $$ = nullptr; }                                                               // FIX ME
     1027        when_clause_opt waitfor statement                                       %prec THEN
     1028                { $$ = new StatementNode( build_waitfor( $2, $3, $1 ) ); }
    10141029        | when_clause_opt waitfor statement WOR waitfor_clause
    1015                 { $$ = nullptr; }                                                               // FIX ME
     1030                { $$ = new StatementNode( build_waitfor( $2, $3, $1, $5 ) ); }
    10161031        ;
    10171032
Note: See TracChangeset for help on using the changeset viewer.