Ignore:
Timestamp:
Aug 25, 2017, 10:38:34 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
800d275
Parents:
af08051 (diff), 3eab308c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    raf08051 r28e58fd  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 20 09:21:54 2017
    13 // Update Count     : 2573
     12// Last Modified On : Wed Aug 23 21:08:08 2017
     13// Update Count     : 2704
    1414//
    1515
     
    119119%token RESTRICT                                                                                 // C99
    120120%token ATOMIC                                                                                   // C11
    121 %token FORALL LVALUE MUTEX VIRTUAL                                              // CFA
     121%token FORALL MUTEX VIRTUAL                                             // CFA
    122122%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    123123%token BOOL COMPLEX IMAGINARY                                                   // C99
     
    131131%token ATTRIBUTE EXTENSION                                                              // GCC
    132132%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    133 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH // CFA
     133%token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA
    134134%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    135135%token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
     
    137137// names and constants: lexer differentiates between identifier and typedef names
    138138%token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
     139%token<tok> TIMEOUT                             WOR
    139140%token<tok> ATTR_IDENTIFIER             ATTR_TYPEDEFname                ATTR_TYPEGENname
    140141%token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
     
    161162%type<tok> identifier  no_attr_identifier
    162163%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
     164%type<tok> quasi_keyword
    163165%type<constant> string_literal
    164166%type<str> string_literal_list
     
    190192%type<sn> iteration_statement                   jump_statement
    191193%type<sn> with_statement                                exception_statement                     asm_statement
     194%type<sn> when_clause_opt                               waitfor_statement                       waitfor_clause                          waitfor                         timeout
    192195%type<sn> fall_through_opt                              fall_through
    193196%type<sn> statement                                             statement_list
     
    197200%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    198201%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    199 %type<sn> /* handler_list */                    handler_clause                          finally_clause
     202%type<sn> handler_clause                                finally_clause
    200203%type<catch_kind> handler_key
    201204
     
    295298// Handle single shift/reduce conflict for dangling else by shifting the ELSE token. For example, this string
    296299// is ambiguous:
    297 // .---------.                          matches IF '(' comma_expression ')' statement
     300// .---------.                          matches IF '(' comma_expression ')' statement . (reduce)
    298301// if ( C ) S1 else S2
    299 // `-----------------'          matches IF '(' comma_expression ')' statement ELSE statement */
    300 
    301 %nonassoc THEN  // rule precedence for IF '(' comma_expression ')' statement
    302 %nonassoc ELSE  // token precedence for start of else clause in IF statement
     302// `-----------------'          matches IF '(' comma_expression ')' statement . (shift) ELSE statement */
     303// Similar issues exit with the waitfor statement.
     304
     305// Order of these lines matters (low-to-high precedence). THEN is left associative over WOR/TIMEOUT/ELSE, WOR is left
     306// associative over TIMEOUT/ELSE, and TIMEOUT is left associative over ELSE.
     307%precedence THEN        // rule precedence for IF/WAITFOR statement
     308%precedence WOR         // token precedence for start of WOR in WAITFOR statement
     309%precedence TIMEOUT     // token precedence for start of TIMEOUT in WAITFOR statement
     310%precedence ELSE        // token precedence for start of else clause in IF/WAITFOR statement
    303311
    304312%start translation_unit                                                                 // parse-tree root
     
    353361        ;
    354362
     363quasi_keyword:                                                                                  // CFA
     364        TIMEOUT
     365        | WOR
     366        ;
     367
    355368identifier:
    356369        IDENTIFIER
    357370        | ATTR_IDENTIFIER                                                                       // CFA
     371        | quasi_keyword
    358372        ;
    359373
    360374no_attr_identifier:
    361375        IDENTIFIER
     376        | quasi_keyword
    362377        ;
    363378
     
    380395primary_expression:
    381396        IDENTIFIER                                                                                      // typedef name cannot be used as a variable name
     397                { $$ = new ExpressionNode( build_varref( $1 ) ); }
     398        | quasi_keyword
    382399                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    383400        | tuple
     
    548565        | '&'                                                                           { $$ = OperKinds::AddressOf; }
    549566                // GCC, address of label must be handled by semantic check for ref,ref,label
    550 //      | ANDAND                                                                        { $$ = OperKinds::And; }
     567        | ANDAND                                                                        { $$ = OperKinds::And; }
    551568        ;
    552569
     
    670687        conditional_expression
    671688        | unary_expression assignment_operator assignment_expression
    672                 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); }
     689                { $$ = new ExpressionNode( build_binary_val( $2, $1, $3 ) ); }
    673690        ;
    674691
     
    736753        | jump_statement
    737754        | with_statement
     755        | waitfor_statement
    738756        | exception_statement
    739757        | asm_statement
     
    955973
    956974with_statement:
    957         WITH '(' tuple_expression_list ')' compound_statement
    958                 { $$ = (StatementNode *)0; }                                    // FIX ME
     975        WITH '(' tuple_expression_list ')' statement
     976                { $$ = nullptr; }                                                               // FIX ME
     977        ;
     978
     979when_clause_opt:
     980        // empty
     981                { $$ = nullptr; }                                                               // FIX ME
     982        | WHEN '(' comma_expression ')'
     983                { $$ = nullptr; }                                                               // FIX ME
     984        ;
     985
     986waitfor:
     987        WAITFOR '(' identifier ')'
     988                { $$ = nullptr; }                                                               // FIX ME
     989        | WAITFOR '(' identifier ',' argument_expression_list ')'
     990                { $$ = nullptr; }                                                               // FIX ME
     991        ;
     992
     993timeout:
     994        TIMEOUT '(' comma_expression ')'
     995                { $$ = nullptr; }                                                               // FIX ME
     996        ;
     997
     998waitfor_clause:
     999        when_clause_opt waitfor statement %prec THEN
     1000                { $$ = nullptr; }                                                               // FIX ME
     1001        | when_clause_opt waitfor statement WOR waitfor_clause
     1002                { $$ = nullptr; }                                                               // FIX ME
     1003        | when_clause_opt timeout statement %prec THEN
     1004                { $$ = nullptr; }                                                               // FIX ME
     1005        | 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
     1009        ;
     1010
     1011waitfor_statement:
     1012        when_clause_opt waitfor statement %prec THEN
     1013                { $$ = nullptr; }                                                               // FIX ME
     1014        | when_clause_opt waitfor statement WOR waitfor_clause
     1015                { $$ = nullptr; }                                                               // FIX ME
    9591016        ;
    9601017
     
    9671024                { $$ = new StatementNode( build_try( $2, $3, $4 ) ); }
    9681025        ;
    969 
    970 //handler_list:
    971 //      handler_clause
    972 //              // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block.
    973 //      | CATCH '(' ELLIPSIS ')' compound_statement
    974 //              { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
    975 //      | handler_clause CATCH '(' ELLIPSIS ')' compound_statement
    976 //              { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
    977 //      | CATCHRESUME '(' ELLIPSIS ')' compound_statement
    978 //              { $$ = new StatementNode( build_catch( 0, $5, true ) ); }
    979 //      | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement
    980 //              { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); }
    981 //      ;
    9821026
    9831027handler_clause:
     
    14391483        | VOLATILE
    14401484                { $$ = DeclarationNode::newTypeQualifier( Type::Volatile ); }
    1441         | LVALUE                                                                                        // CFA
    1442                 { $$ = DeclarationNode::newTypeQualifier( Type::Lvalue ); }
    14431485        | MUTEX
    14441486                { $$ = DeclarationNode::newTypeQualifier( Type::Mutex ); }
     
    22412283with_clause_opt:
    22422284        // empty
    2243                 { $$ = (StatementNode *)0; }                                    // FIX ME
     2285                { $$ = nullptr; }                                                               // FIX ME
    22442286        | WITH '(' tuple_expression_list ')'
    2245                 { $$ = (StatementNode *)0; }                                    // FIX ME
     2287                { $$ = nullptr; }                                                               // FIX ME
    22462288        ;
    22472289
     
    23632405attr_name:                                                                                              // GCC
    23642406        IDENTIFIER
     2407        | quasi_keyword
    23652408        | TYPEDEFname
    23662409        | TYPEGENname
     
    24212464variable_ptr:
    24222465        ptrref_operator variable_declarator
    2423                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2466                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    24242467        | ptrref_operator type_qualifier_list variable_declarator
    2425                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2468                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    24262469        | '(' variable_ptr ')' attribute_list_opt
    24272470                { $$ = $2->addQualifiers( $4 ); }                               // redundant parenthesis
     
    24692512function_ptr:
    24702513        ptrref_operator function_declarator
    2471                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2514                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    24722515        | ptrref_operator type_qualifier_list function_declarator
    2473                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2516                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    24742517        | '(' function_ptr ')'
    24752518                { $$ = $2; }
     
    25092552KR_function_ptr:
    25102553        ptrref_operator KR_function_declarator
    2511                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2554                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    25122555        | ptrref_operator type_qualifier_list KR_function_declarator
    2513                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2556                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    25142557        | '(' KR_function_ptr ')'
    25152558                { $$ = $2; }
     
    25532596type_ptr:
    25542597        ptrref_operator variable_type_redeclarator
    2555                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2598                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    25562599        | ptrref_operator type_qualifier_list variable_type_redeclarator
    2557                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2600                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    25582601        | '(' type_ptr ')' attribute_list_opt
    25592602                { $$ = $2->addQualifiers( $4 ); }
     
    25972640identifier_parameter_ptr:
    25982641        ptrref_operator identifier_parameter_declarator
    2599                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2642                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    26002643        | ptrref_operator type_qualifier_list identifier_parameter_declarator
    2601                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2644                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    26022645        | '(' identifier_parameter_ptr ')' attribute_list_opt
    26032646                { $$ = $2->addQualifiers( $4 ); }
     
    26572700type_parameter_ptr:
    26582701        ptrref_operator type_parameter_redeclarator
    2659                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2702                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    26602703        | ptrref_operator type_qualifier_list type_parameter_redeclarator
    2661                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2704                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    26622705        | '(' type_parameter_ptr ')' attribute_list_opt
    26632706                { $$ = $2->addQualifiers( $4 ); }
     
    27002743abstract_ptr:
    27012744        ptrref_operator
    2702                 { $$ = DeclarationNode::newPointer( 0 ); }
     2745                { $$ = DeclarationNode::newPointer( 0, $1 ); }
    27032746        | ptrref_operator type_qualifier_list
    2704                 { $$ = DeclarationNode::newPointer( $2 ); }
     2747                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    27052748        | ptrref_operator abstract_declarator
    2706                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2749                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    27072750        | ptrref_operator type_qualifier_list abstract_declarator
    2708                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2751                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    27092752        | '(' abstract_ptr ')' attribute_list_opt
    27102753                { $$ = $2->addQualifiers( $4 ); }
     
    27892832abstract_parameter_ptr:
    27902833        ptrref_operator
    2791                 { $$ = DeclarationNode::newPointer( nullptr ); }
     2834                { $$ = DeclarationNode::newPointer( nullptr, $1 ); }
    27922835        | ptrref_operator type_qualifier_list
    2793                 { $$ = DeclarationNode::newPointer( $2 ); }
     2836                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    27942837        | ptrref_operator abstract_parameter_declarator
    2795                 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr ) ); }
     2838                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    27962839        | ptrref_operator type_qualifier_list abstract_parameter_declarator
    2797                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2840                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    27982841        | '(' abstract_parameter_ptr ')' attribute_list_opt
    27992842                { $$ = $2->addQualifiers( $4 ); }
     
    28682911variable_abstract_ptr:
    28692912        ptrref_operator
    2870                 { $$ = DeclarationNode::newPointer( 0 ); }
     2913                { $$ = DeclarationNode::newPointer( 0, $1 ); }
    28712914        | ptrref_operator type_qualifier_list
    2872                 { $$ = DeclarationNode::newPointer( $2 ); }
     2915                { $$ = DeclarationNode::newPointer( $2, $1 ); }
    28732916        | ptrref_operator variable_abstract_declarator
    2874                 { $$ = $2->addPointer( DeclarationNode::newPointer( 0 ) ); }
     2917                { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    28752918        | ptrref_operator type_qualifier_list variable_abstract_declarator
    2876                 { $$ = $3->addPointer( DeclarationNode::newPointer( $2 ) ); }
     2919                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    28772920        | '(' variable_abstract_ptr ')' attribute_list_opt
    28782921                { $$ = $2->addQualifiers( $4 ); }
     
    29142957                // No SUE declaration in parameter list.
    29152958        ptrref_operator type_specifier_nobody
    2916                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2959                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    29172960        | type_qualifier_list ptrref_operator type_specifier_nobody
    2918                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2961                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    29192962        | ptrref_operator cfa_abstract_function
    2920                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2963                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    29212964        | type_qualifier_list ptrref_operator cfa_abstract_function
    2922                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2965                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    29232966        | ptrref_operator cfa_identifier_parameter_declarator_tuple
    2924                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     2967                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    29252968        | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple
    2926                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     2969                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    29272970        ;
    29282971
     
    30023045cfa_abstract_ptr:                                                                               // CFA
    30033046        ptrref_operator type_specifier
    3004                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     3047                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    30053048        | type_qualifier_list ptrref_operator type_specifier
    3006                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     3049                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    30073050        | ptrref_operator cfa_abstract_function
    3008                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     3051                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    30093052        | type_qualifier_list ptrref_operator cfa_abstract_function
    3010                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     3053                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    30113054        | ptrref_operator cfa_abstract_declarator_tuple
    3012                 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
     3055                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); }
    30133056        | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple
    3014                 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
     3057                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); }
    30153058        ;
    30163059
Note: See TracChangeset for help on using the changeset viewer.