Ignore:
Timestamp:
Mar 4, 2017, 10:31:03 PM (9 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:
3f80888
Parents:
c3ebf37 (diff), 8191203 (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:

add signed/unsigned char to I/O

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rc3ebf37 rd107010  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 15:56:33 2017
    13 // Update Count     : 2186
     12// Last Modified On : Fri Mar  3 21:35:28 2017
     13// Update Count     : 2222
    1414//
    1515
     
    196196
    197197%type<aggKey> aggregate_key
    198 %type<decl>  aggregate_type
     198%type<decl> aggregate_type aggregate_type_nobody
    199199
    200200%type<decl> assertion assertion_list_opt
     
    207207
    208208%type<decl> declaration declaration_list declaration_list_opt declaration_qualifier_list
    209 %type<decl> declaration_specifier declarator declaring_list
    210 
    211 %type<decl> elaborated_type
    212 
    213 %type<decl> enumerator_list enum_type
     209%type<decl> declaration_specifier declaration_specifier_nobody declarator declaring_list
     210
     211%type<decl> elaborated_type elaborated_type_nobody
     212
     213%type<decl> enumerator_list enum_type enum_type_nobody
    214214%type<en> enumerator_value_opt
    215215
     
    251251%type<decl> storage_class storage_class_list
    252252
    253 %type<decl> sue_declaration_specifier sue_type_specifier
     253%type<decl> sue_declaration_specifier sue_declaration_specifier_nobody sue_type_specifier sue_type_specifier_nobody
    254254
    255255%type<tclass> type_class
     
    268268%type<en> type_name_list
    269269
    270 %type<decl> type_qualifier type_qualifier_name type_qualifier_list type_qualifier_list_opt type_specifier
     270%type<decl> type_qualifier type_qualifier_name type_qualifier_list type_qualifier_list_opt type_specifier type_specifier_nobody
    271271
    272272%type<decl> variable_declarator variable_ptr variable_array variable_function
     
    973973
    974974exception_declaration:
    975                 // A semantic check is required to ensure type_specifier does not create a new type, e.g.:
    976                 //
    977                 //              catch ( struct { int i; } x ) ...
    978                 //
    979                 // This new type cannot catch any thrown type because of name equivalence among types.
    980         type_specifier
    981         | type_specifier declarator
     975                // No SUE declaration in parameter list.
     976        type_specifier_nobody
     977        | type_specifier_nobody declarator
    982978                {
    983979                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    984980                        $$ = $2->addType( $1 );
    985981                }
    986         | type_specifier variable_abstract_declarator
     982        | type_specifier_nobody variable_abstract_declarator
    987983                { $$ = $2->addType( $1 ); }
    988984        | cfa_abstract_declarator_tuple no_attr_identifier      // CFA
     
    13491345        ;
    13501346
    1351 type_specifier:                                                                                 // declaration specifier - storage class
     1347declaration_specifier_nobody:                                                   // type specifier + storage class - {...}
     1348                // Preclude SUE declarations in restricted scopes:
     1349                //
     1350                //    int f( struct S { int i; } s1, Struct S s2 ) { struct S s3; ... }
     1351                //
     1352                // because it is impossible to call f due to name equivalence.
     1353        basic_declaration_specifier
     1354        | sue_declaration_specifier_nobody
     1355        | typedef_declaration_specifier
     1356        | typegen_declaration_specifier
     1357        ;
     1358
     1359type_specifier:                                                                                 // type specifier
    13521360        basic_type_specifier
    13531361        | sue_type_specifier
     1362        | typedef_type_specifier
     1363        | typegen_type_specifier
     1364        ;
     1365
     1366type_specifier_nobody:                                                                  // type specifier - {...}
     1367                // Preclude SUE declarations in restricted scopes:
     1368                //
     1369                //    int f( struct S { int i; } s1, Struct S s2 ) { struct S s3; ... }
     1370                //
     1371                // because it is impossible to call f due to name equivalence.
     1372        basic_type_specifier
     1373        | sue_type_specifier_nobody
    13541374        | typedef_type_specifier
    13551375        | typegen_type_specifier
     
    13801400type_qualifier_name:
    13811401        CONST
    1382                 { $$ = DeclarationNode::newQualifier( DeclarationNode::Const ); }
     1402                { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Const ); }
    13831403        | RESTRICT
    1384                 { $$ = DeclarationNode::newQualifier( DeclarationNode::Restrict ); }
     1404                { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Restrict ); }
    13851405        | VOLATILE
    1386                 { $$ = DeclarationNode::newQualifier( DeclarationNode::Volatile ); }
     1406                { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Volatile ); }
    13871407        | LVALUE                                                                                        // CFA
    1388                 { $$ = DeclarationNode::newQualifier( DeclarationNode::Lvalue ); }
     1408                { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Lvalue ); }
    13891409        | ATOMIC
    1390                 { $$ = DeclarationNode::newQualifier( DeclarationNode::Atomic ); }
     1410                { $$ = DeclarationNode::newTypeQualifier( DeclarationNode::Atomic ); }
    13911411        | FORALL '('
    13921412                {
     
    14281448        | REGISTER
    14291449                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Register ); }
    1430         | INLINE                                                                                        // C99
    1431                 //{ $$ = DeclarationNode::newStorageClass( DeclarationNode::Inline ); }
    1432                 { $$ = new DeclarationNode; $$->isInline = true; }
    1433         | FORTRAN                                                                                       // C99
    1434                 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Fortran ); }
    1435         | NORETURN                                                                                      // C11
    1436                 //{ $$ = DeclarationNode::newStorageClass( DeclarationNode::Noreturn ); }
    1437                 { $$ = new DeclarationNode; $$->isNoreturn = true; }
    14381450        | THREADLOCAL                                                                           // C11
    14391451                { $$ = DeclarationNode::newStorageClass( DeclarationNode::Threadlocal ); }
     1452                // Put function specifiers here to simplify parsing rules, but separate them semantically.
     1453        | INLINE                                                                                        // C99
     1454                { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); }
     1455        | FORTRAN                                                                                       // C99
     1456                { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); }
     1457        | NORETURN                                                                                      // C11
     1458                { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); }
    14401459        ;
    14411460
     
    15141533        ;
    15151534
    1516 sue_declaration_specifier:
     1535sue_declaration_specifier:                                                              // struct, union, enum + storage class + type specifier
    15171536        sue_type_specifier
    15181537        | declaration_qualifier_list sue_type_specifier
     
    15241543        ;
    15251544
    1526 sue_type_specifier:
    1527         elaborated_type                                                                         // struct, union, enum
     1545sue_type_specifier:                                                                             // struct, union, enum + type specifier
     1546        elaborated_type
    15281547        | type_qualifier_list elaborated_type
    15291548                { $$ = $2->addQualifiers( $1 ); }
    15301549        | sue_type_specifier type_qualifier
     1550                { $$ = $1->addQualifiers( $2 ); }
     1551        ;
     1552
     1553sue_declaration_specifier_nobody:                                               // struct, union, enum - {...} + storage class + type specifier
     1554        sue_type_specifier_nobody
     1555        | declaration_qualifier_list sue_type_specifier_nobody
     1556                { $$ = $2->addQualifiers( $1 ); }
     1557        | sue_declaration_specifier_nobody storage_class        // remaining OBSOLESCENT (see 2)
     1558                { $$ = $1->addQualifiers( $2 ); }
     1559        | sue_declaration_specifier_nobody storage_class type_qualifier_list
     1560                { $$ = $1->addQualifiers( $2 )->addQualifiers( $3 ); }
     1561        ;
     1562
     1563sue_type_specifier_nobody:                                                              // struct, union, enum - {...} + type specifier
     1564        elaborated_type_nobody
     1565        | type_qualifier_list elaborated_type_nobody
     1566                { $$ = $2->addQualifiers( $1 ); }
     1567        | sue_type_specifier_nobody type_qualifier
    15311568                { $$ = $1->addQualifiers( $2 ); }
    15321569        ;
     
    15511588        ;
    15521589
    1553 elaborated_type:
     1590elaborated_type:                                                                                // struct, union, enum
    15541591        aggregate_type
    15551592        | enum_type
    15561593        ;
    15571594
    1558 aggregate_type:
     1595elaborated_type_nobody:                                                                 // struct, union, enum - {...}
     1596        aggregate_type_nobody
     1597        | enum_type_nobody
     1598        ;
     1599
     1600aggregate_type:                                                                                 // struct, union
    15591601        aggregate_key attribute_list_opt '{' field_declaration_list '}'
    15601602                { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $4, true )->addQualifiers( $2 ); }
    1561         | aggregate_key attribute_list_opt no_attr_identifier_or_type_name
    1562                 {
    1563                         typedefTable.makeTypedef( *$3 );
    1564                         $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
    1565                 }
    15661603        | aggregate_key attribute_list_opt no_attr_identifier_or_type_name
    15671604                { typedefTable.makeTypedef( *$3 ); }
     
    15701607        | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    15711608                { $$ = DeclarationNode::newAggregate( $1, nullptr, $4, $7, false )->addQualifiers( $2 ); }
     1609        | aggregate_type_nobody
     1610        ;
     1611
     1612aggregate_type_nobody:                                                                  // struct, union - {...}
     1613        aggregate_key attribute_list_opt no_attr_identifier_or_type_name
     1614                {
     1615                        typedefTable.makeTypedef( *$3 );
     1616                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
     1617                }
    15721618        | aggregate_key attribute_list_opt typegen_name         // CFA, S/R conflict
    15731619                { $$ = $3->addQualifiers( $2 ); }
     
    16471693        ;
    16481694
    1649 enum_type:
     1695enum_type:                                                                                              // enum
    16501696        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    1651                 { $$ = DeclarationNode::newEnum( nullptr, $4 )->addQualifiers( $2 ); }
    1652         | ENUM attribute_list_opt no_attr_identifier_or_type_name
    1653                 {
    1654                         typedefTable.makeTypedef( *$3 );
    1655                         $$ = DeclarationNode::newEnum( $3, 0 )->addQualifiers( $2 );
    1656                 }
     1697                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
    16571698        | ENUM attribute_list_opt no_attr_identifier_or_type_name
    16581699                { typedefTable.makeTypedef( *$3 ); }
    16591700          '{' enumerator_list comma_opt '}'
    1660                 { $$ = DeclarationNode::newEnum( $3, $6 )->addQualifiers( $2 ); }
     1701                { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); }
     1702        | enum_type_nobody
     1703        ;
     1704
     1705enum_type_nobody:                                                                               // enum - {...}
     1706        ENUM attribute_list_opt no_attr_identifier_or_type_name
     1707                {
     1708                        typedefTable.makeTypedef( *$3 );
     1709                        $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 );
     1710                }
    16611711        ;
    16621712
     
    17591809
    17601810parameter_declaration:
    1761         declaration_specifier identifier_parameter_declarator assignment_opt
     1811                // No SUE declaration in parameter list.
     1812        declaration_specifier_nobody identifier_parameter_declarator assignment_opt
    17621813                {
    17631814                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    17641815                        $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
    17651816                }
    1766         | declaration_specifier type_parameter_redeclarator assignment_opt
     1817        | declaration_specifier_nobody type_parameter_redeclarator assignment_opt
    17671818                {
    17681819                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    17721823
    17731824abstract_parameter_declaration:
    1774         declaration_specifier assignment_opt
     1825        declaration_specifier_nobody assignment_opt
    17751826                { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); }
    1776         | declaration_specifier abstract_parameter_declarator assignment_opt
     1827        | declaration_specifier_nobody abstract_parameter_declarator assignment_opt
    17771828                { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); }
    17781829        ;
     
    27982849
    27992850cfa_identifier_parameter_ptr:                                                   // CFA
    2800         ptrref_operator type_specifier
     2851                // No SUE declaration in parameter list.
     2852        ptrref_operator type_specifier_nobody
    28012853                { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0 ) ); }
    2802         | type_qualifier_list ptrref_operator type_specifier
     2854        | type_qualifier_list ptrref_operator type_specifier_nobody
    28032855                { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1 ) ); }
    28042856        | ptrref_operator cfa_abstract_function
     
    28152867                // Only the first dimension can be empty or have qualifiers. Empty dimension must be factored out due to
    28162868                // shift/reduce conflict with new-style empty (void) function return type.
    2817         '[' ']' type_specifier
     2869        '[' ']' type_specifier_nobody
    28182870                { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    2819         | cfa_array_parameter_1st_dimension type_specifier
     2871        | cfa_array_parameter_1st_dimension type_specifier_nobody
    28202872                { $$ = $2->addNewArray( $1 ); }
    2821         | '[' ']' multi_array_dimension type_specifier
     2873        | '[' ']' multi_array_dimension type_specifier_nobody
    28222874                { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); }
    2823         | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier
     2875        | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody
    28242876                { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); }
    2825         | multi_array_dimension type_specifier
     2877        | multi_array_dimension type_specifier_nobody
    28262878                { $$ = $2->addNewArray( $1 ); }
    28272879
Note: See TracChangeset for help on using the changeset viewer.