Ignore:
Timestamp:
Apr 15, 2016, 12:03:11 PM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
29ad0ac
Parents:
c5833e8 (diff), 37f0da8 (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' into gc_noraii

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rc5833e8 r0f9e4403  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb  1 18:22:42 2016
    13 // Update Count     : 1483
     12// Last Modified On : Wed Apr 13 16:58:43 2016
     13// Update Count     : 1519
    1414//
    1515
     
    5151#include <cstdio>
    5252#include <stack>
     53#include "lex.h"
     54#include "parser.h"
     55#include "ParseNode.h"
    5356#include "TypedefTable.h"
    54 #include "lex.h"
    55 #include "ParseNode.h"
    5657#include "TypeData.h"
    5758#include "LinkageSpec.h"
     
    7475%token FORALL LVALUE                                                                    // CFA
    7576%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
     77%token VALIST                                                                                   // GCC
    7678%token BOOL COMPLEX IMAGINARY                                                   // C99
    7779%token TYPEOF LABEL                                                                             // GCC
    7880%token ENUM STRUCT UNION
    79 %token TYPE FTYPE DTYPE CONTEXT                                                 // CFA
     81%token OTYPE FTYPE DTYPE TRAIT                                          // CFA
    8082%token SIZEOF OFFSETOF
    8183%token ATTRIBUTE EXTENSION                                                              // GCC
     
    171173%type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type_name indirect_type_name
    172174
    173 %type<decl> context_declaration context_declaration_list context_declaring_list context_specifier
     175%type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier
    174176
    175177%type<decl> declaration declaration_list declaration_list_opt declaration_qualifier_list
     
    197199%type<decl> new_array_parameter_1st_dimension
    198200
    199 %type<decl> new_context_declaring_list new_declaration new_field_declaring_list
     201%type<decl> new_trait_declaring_list new_declaration new_field_declaring_list
    200202%type<decl> new_function_declaration new_function_return new_function_specifier
    201203
     
    370372                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::DecrPost ), $1 ); }
    371373        | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99
    372                 { $$ = 0; }
     374                { $$ = new CompoundLiteralNode( $2, new InitializerNode( $5, true ) ); }
    373375        | postfix_expression '{' argument_expression_list '}' // CFA
    374376                {
     
    448450                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( $3 )); }
    449451        | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')'
    450         { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); }
     452                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); }
    451453        | ATTR_IDENTIFIER
    452454                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 )); }
     
    10201022        | new_function_declaration pop ';'
    10211023        | type_declaring_list pop ';'
    1022         | context_specifier pop ';'
     1024        | trait_specifier pop ';'
    10231025        ;
    10241026
     
    10271029                {
    10281030                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1029                         $$ = $1;
     1031                        $$ = $1->addInitializer( $2 );
    10301032                }
    10311033        | declaration_qualifier_list new_variable_specifier initializer_opt
     
    10341036                {
    10351037                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1036                         $$ = $2->addQualifiers( $1 );
     1038                        $$ = $2->addQualifiers( $1 )->addInitializer( $3 );;
    10371039                }
    10381040        | new_variable_declaration pop ',' push identifier_or_type_name initializer_opt
    10391041                {
    10401042                        typedefTable.addToEnclosingScope( *$5, TypedefTable::ID );
    1041                         $$ = $1->appendList( $1->cloneType( $5 ) );
     1043                        $$ = $1->appendList( $1->cloneType( $5 )->addInitializer( $6 ) );
    10421044                }
    10431045        ;
     
    13451347        | IMAGINARY                                                                                     // C99
    13461348                { $$ = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); }
     1349        | VALIST                                                                                        // GCC, __builtin_va_list
     1350                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    13471351        ;
    13481352
     
    14341438                { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3 ); }
    14351439        | aggregate_key no_attr_identifier_or_type_name
    1436                 { $$ = DeclarationNode::newAggregate( $1, $2, 0, 0 ); }
    1437         | aggregate_key no_attr_identifier_or_type_name '{' field_declaration_list '}'
    1438                 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $4 ); }
     1440                {
     1441                        typedefTable.makeTypedef( *$2 );
     1442                        $$ = DeclarationNode::newAggregate( $1, $2, 0, 0 );
     1443                }
     1444        | aggregate_key no_attr_identifier_or_type_name
     1445                { typedefTable.makeTypedef( *$2 ); }
     1446                '{' field_declaration_list '}'
     1447                { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5); }
    14391448        | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    1440                 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); }
     1449                { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); }
    14411450        | aggregate_key typegen_name                                            // CFA, S/R conflict
    14421451                { $$ = $2; }
     
    15161525        enum_key '{' enumerator_list comma_opt '}'
    15171526                { $$ = DeclarationNode::newEnum( 0, $3 ); }
    1518         | enum_key no_attr_identifier_or_type_name '{' enumerator_list comma_opt '}'
    1519                 { $$ = DeclarationNode::newEnum( $2, $4 ); }
    15201527        | enum_key no_attr_identifier_or_type_name
    1521                 { $$ = DeclarationNode::newEnum( $2, 0 ); }
     1528                {
     1529                        typedefTable.makeTypedef( *$2 );
     1530                        $$ = DeclarationNode::newEnum( $2, 0 );
     1531                }
     1532        | enum_key no_attr_identifier_or_type_name
     1533                { typedefTable.makeTypedef( *$2 ); }
     1534                '{' enumerator_list comma_opt '}'
     1535                { $$ = DeclarationNode::newEnum( $2, $5 ); }
    15221536        ;
    15231537
     
    18031817
    18041818type_class:                                                                                             // CFA
    1805         TYPE
     1819        OTYPE
    18061820                { $$ = DeclarationNode::Type; }
    18071821        | DTYPE
     
    18211835        '|' no_attr_identifier_or_type_name '(' type_name_list ')'
    18221836                {
    1823                         typedefTable.openContext( *$2 );
    1824                         $$ = DeclarationNode::newContextUse( $2, $4 );
    1825                 }
    1826         | '|' '{' push context_declaration_list '}'
     1837                        typedefTable.openTrait( *$2 );
     1838                        $$ = DeclarationNode::newTraitUse( $2, $4 );
     1839                }
     1840        | '|' '{' push trait_declaration_list '}'
    18271841                { $$ = $4; }
    1828         | '|' '(' push type_parameter_list pop ')' '{' push context_declaration_list '}' '(' type_name_list ')'
     1842        | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')'
    18291843                { $$ = 0; }
    18301844        ;
     
    18411855
    18421856type_declaring_list:                                                                    // CFA
    1843         TYPE type_declarator
    1844                 { $$ = $2; }
    1845         | storage_class_list TYPE type_declarator
     1857        OTYPE type_declarator
     1858                { $$ = $2; }
     1859        | storage_class_list OTYPE type_declarator
    18461860                { $$ = $3->addQualifiers( $1 ); }
    18471861        | type_declaring_list ',' type_declarator
     
    18691883        ;
    18701884
    1871 context_specifier:                                                                              // CFA
    1872         CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
     1885trait_specifier:                                                                                // CFA
     1886        TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
    18731887                {
    18741888                        typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
    1875                         $$ = DeclarationNode::newContext( $2, $5, 0 );
    1876                 }
    1877         | CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'
    1878                 {
    1879                         typedefTable.enterContext( *$2 );
     1889                        $$ = DeclarationNode::newTrait( $2, $5, 0 );
     1890                }
     1891        | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'
     1892                {
     1893                        typedefTable.enterTrait( *$2 );
    18801894                        typedefTable.enterScope();
    18811895                }
    1882           context_declaration_list '}'
    1883                 {
    1884                         typedefTable.leaveContext();
     1896          trait_declaration_list '}'
     1897                {
     1898                        typedefTable.leaveTrait();
    18851899                        typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
    1886                         $$ = DeclarationNode::newContext( $2, $5, $10 );
    1887                 }
    1888         ;
    1889 
    1890 context_declaration_list:                                                               // CFA
    1891         context_declaration
    1892         | context_declaration_list push context_declaration
     1900                        $$ = DeclarationNode::newTrait( $2, $5, $10 );
     1901                }
     1902        ;
     1903
     1904trait_declaration_list:                                                         // CFA
     1905        trait_declaration
     1906        | trait_declaration_list push trait_declaration
    18931907                { $$ = $1->appendList( $3 ); }
    18941908        ;
    18951909
    1896 context_declaration:                                                                    // CFA
    1897         new_context_declaring_list pop ';'
    1898         | context_declaring_list pop ';'
    1899         ;
    1900 
    1901 new_context_declaring_list:                                                             // CFA
     1910trait_declaration:                                                                      // CFA
     1911        new_trait_declaring_list pop ';'
     1912        | trait_declaring_list pop ';'
     1913        ;
     1914
     1915new_trait_declaring_list:                                                               // CFA
    19021916        new_variable_specifier
    19031917                {
     
    19101924                        $$ = $1;
    19111925                }
    1912         | new_context_declaring_list pop ',' push identifier_or_type_name
     1926        | new_trait_declaring_list pop ',' push identifier_or_type_name
    19131927                {
    19141928                        typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID );
     
    19171931        ;
    19181932
    1919 context_declaring_list:                                                                 // CFA
     1933trait_declaring_list:                                                                   // CFA
    19201934        type_specifier declarator
    19211935                {
     
    19231937                        $$ = $2->addType( $1 );
    19241938                }
    1925         | context_declaring_list pop ',' push declarator
     1939        | trait_declaring_list pop ',' push declarator
    19261940                {
    19271941                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
     
    28092823        std::cout << "Error ";
    28102824        if ( yyfilename ) {
    2811             std::cout << "in file " << yyfilename << " ";
     2825                std::cout << "in file " << yyfilename << " ";
    28122826        } // if
    28132827        std::cout << "at line " << yylineno << " reading token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << "\"" << std::endl;
Note: See TracChangeset for help on using the changeset viewer.