Ignore:
Timestamp:
Aug 26, 2017, 5:31:20 PM (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:
9bd6105
Parents:
a16d833
Message:

change waitfor syntax so else must have when-clause after timeout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    ra16d833 r51d6d6a  
    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 14:41:43 2017
     13// Update Count     : 2711
    1414//
    1515
     
    120120%token RESTRICT                                                                                 // C99
    121121%token ATOMIC                                                                                   // C11
    122 %token FORALL MUTEX VIRTUAL                                             // CFA
     122%token FORALL MUTEX VIRTUAL                                                             // CFA
    123123%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    124124%token BOOL COMPLEX IMAGINARY                                                   // C99
     
    188188%type<flag> asm_volatile_opt
    189189%type<en> handler_predicate_opt
    190 %type<en> when_clause_opt timeout
    191190
    192191// statements
    193192%type<sn> labeled_statement                             compound_statement                      expression_statement            selection_statement
    194193%type<sn> iteration_statement                   jump_statement
    195 %type<sn> with_statement                                exception_statement                     asm_statement
     194%type<sn> with_clause_opt                               with_statement
     195%type<sn> exception_statement                   handler_clause                          finally_clause
     196%type<catch_kind> handler_key
     197%type<en> when_clause                                   when_clause_opt                         timeout
    196198%type<sn> waitfor_statement
    197 %type<sn> fall_through_opt                              fall_through
    198 %type<sn> statement                                             statement_list
     199%type<en> waitfor
     200%type<wfs> waitfor_clause
     201%type<sn> statement                                             statement_list                          asm_statement
    199202%type<sn> block_item_list                               block_item
    200 %type<sn> with_clause_opt
    201203%type<en> case_value
    202204%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    203205%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    204 %type<sn> handler_clause                                finally_clause
    205 %type<catch_kind> handler_key
    206 %type<wfs> waitfor_clause
    207 %type<en> waitfor
     206%type<sn> fall_through                                  fall_through_opt
    208207
    209208// declarations
     
    818817
    819818selection_statement:
    820         IF '(' push if_control_expression ')' statement                         %prec THEN
     819        IF '(' push if_control_expression ')' statement         %prec THEN
    821820                // explicitly deal with the shift/reduce conflict on if/else
    822821                { $$ = new StatementNode( build_if( $4, $6, nullptr ) ); }
     
    981980        ;
    982981
     982when_clause:
     983        WHEN '(' comma_expression ')'
     984                { $$ = $3; }
     985        ;
     986
    983987when_clause_opt:
    984988        // empty
    985989                { $$ = nullptr; }
    986         | WHEN '(' comma_expression ')'
    987                 { $$ = $3; }
     990        | when_clause
    988991        ;
    989992
     
    10081011
    10091012waitfor_clause:
    1010         when_clause_opt waitfor statement %prec THEN
     1013        when_clause_opt waitfor statement                                       %prec THEN
    10111014                { $$ = build_waitfor( $2, $3, $1 ); }
    10121015        | when_clause_opt waitfor statement WOR waitfor_clause
    10131016                { $$ = build_waitfor( $2, $3, $1, $5 ); }
    1014         | when_clause_opt timeout statement %prec THEN
     1017        | when_clause_opt timeout statement                                     %prec THEN
    10151018                { $$ = build_waitfor_timeout( $2, $3, $1 ); }
    10161019        | when_clause_opt ELSE statement
    10171020                { $$ = build_waitfor_timeout( nullptr, $3, $1 ); }
    1018         | when_clause_opt timeout statement WOR when_clause_opt ELSE statement
     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
    10191023                { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); }
    10201024        ;
    10211025
    10221026waitfor_statement:
    1023         when_clause_opt waitfor statement %prec THEN
     1027        when_clause_opt waitfor statement                                       %prec THEN
    10241028                { $$ = new StatementNode( build_waitfor( $2, $3, $1 ) ); }
    10251029        | when_clause_opt waitfor statement WOR waitfor_clause
Note: See TracChangeset for help on using the changeset viewer.