Changeset 8b47e50 for src/Parser


Ignore:
Timestamp:
Jul 12, 2017, 9:50:45 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:
ef6851a
Parents:
7812f1d1
Message:

add syntax for "with" clause/statement

Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/lex.ll

    r7812f1d1 r8b47e50  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Tue Jul 11 21:30:51 2017
    13  * Update Count     : 534
     12 * Last Modified On : Wed Jul 12 18:04:44 2017
     13 * Update Count     : 535
    1414 */
    1515
     
    274274__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    275275while                   { KEYWORD_RETURN(WHILE); }
     276with                    { KEYWORD_RETURN(WITH); }                               // CFA
    276277zero_t                  { NUMERIC_RETURN(ZERO_T); }                             // CFA
    277278
  • src/Parser/parser.yy

    r7812f1d1 r8b47e50  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 11 13:39:00 2017
    13 // Update Count     : 2416
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jul 12 18:23:36 2017
     13// Update Count     : 2426
    1414//
    1515
     
    129129%token ATTRIBUTE EXTENSION                                                              // GCC
    130130%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    131 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT        // CFA
     131%token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH   // CFA
    132132%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    133133%token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
     
    184184// statements
    185185%type<sn> labeled_statement                             compound_statement                      expression_statement            selection_statement
    186 %type<sn> iteration_statement                   jump_statement                          exception_statement                     asm_statement
     186%type<sn> iteration_statement                   jump_statement
     187%type<sn> with_statement                                exception_statement                     asm_statement
    187188%type<sn> fall_through_opt                              fall_through
    188189%type<sn> statement                                             statement_list
    189190%type<sn> block_item_list                               block_item
    190 %type<sn> case_clause
     191%type<sn> with_clause_opt
    191192%type<en> case_value
    192 %type<sn> case_value_list                               case_label                                      case_label_list
     193%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    193194%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    194195%type<sn> /* handler_list */                    handler_clause                          finally_clause
     
    729730        | iteration_statement
    730731        | jump_statement
     732        | with_statement
    731733        | exception_statement
    732734        | asm_statement
     
    934936        | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
    935937                { $$ = new StatementNode( build_resume_at( $2, $4 ) ); }
     938        ;
     939
     940with_statement:
     941        WITH identifier_list compound_statement
     942                { $$ = (StatementNode *)0; }                                    // FIX ME
    936943        ;
    937944
     
    22122219        ;
    22132220
     2221with_clause_opt:
     2222        // empty
     2223                { $$ = (StatementNode *)0; }                                    // FIX ME
     2224        | WITH identifier_list
     2225                { $$ = (StatementNode *)0; }                                    // FIX ME
     2226        ;
     2227
    22142228function_definition:
    2215         cfa_function_declaration compound_statement                     // CFA
     2229        cfa_function_declaration with_clause_opt compound_statement     // CFA
    22162230                {
    22172231                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22182232                        typedefTable.leaveScope();
    2219                         $$ = $1->addFunctionBody( $2 );
    2220                 }
    2221         | declaration_specifier function_declarator compound_statement
     2233                        $$ = $1->addFunctionBody( $3 );
     2234                }
     2235        | declaration_specifier function_declarator with_clause_opt compound_statement
    22222236                {
    22232237                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22242238                        typedefTable.leaveScope();
    2225                         $$ = $2->addFunctionBody( $3 )->addType( $1 );
    2226                 }
    2227         | type_qualifier_list function_declarator compound_statement
     2239                        $$ = $2->addFunctionBody( $4 )->addType( $1 );
     2240                }
     2241        | type_qualifier_list function_declarator with_clause_opt compound_statement
    22282242                {
    22292243                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22302244                        typedefTable.leaveScope();
    2231                         $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
    2232                 }
    2233         | declaration_qualifier_list function_declarator compound_statement
     2245                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
     2246                }
     2247        | declaration_qualifier_list function_declarator with_clause_opt compound_statement
    22342248                {
    22352249                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22362250                        typedefTable.leaveScope();
    2237                         $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
    2238                 }
    2239         | declaration_qualifier_list type_qualifier_list function_declarator compound_statement
     2251                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
     2252                }
     2253        | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
    22402254                {
    22412255                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22422256                        typedefTable.leaveScope();
    2243                         $$ = $3->addFunctionBody( $4 )->addQualifiers( $2 )->addQualifiers( $1 );
     2257                        $$ = $3->addFunctionBody( $5 )->addQualifiers( $2 )->addQualifiers( $1 );
    22442258                }
    22452259
    22462260                // Old-style K&R function definition, OBSOLESCENT (see 4)
    2247         | declaration_specifier KR_function_declarator push KR_declaration_list_opt compound_statement
     2261        | declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22482262                {
    22492263                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22502264                        typedefTable.leaveScope();
    2251                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addType( $1 );
    2252                 }
    2253         | type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2265                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addType( $1 );
     2266                }
     2267        | type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22542268                {
    22552269                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22562270                        typedefTable.leaveScope();
    2257                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
     2271                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
    22582272                }
    22592273
    22602274                // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4)
    2261         | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2275        | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22622276                {
    22632277                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22642278                        typedefTable.leaveScope();
    2265                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
    2266                 }
    2267         | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2279                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
     2280                }
     2281        | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22682282                {
    22692283                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22702284                        typedefTable.leaveScope();
    2271                         $$ = $3->addOldDeclList( $5 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 );
     2285                        $$ = $3->addOldDeclList( $5 )->addFunctionBody( $7 )->addQualifiers( $2 )->addQualifiers( $1 );
    22722286                }
    22732287        ;
Note: See TracChangeset for help on using the changeset viewer.