Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rbd85400 r3cfe27f  
    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 : Thu Mar 24 16:16:16 2016
     13// Update Count     : 1498
    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
     
    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
     
    18031807
    18041808type_class:                                                                                             // CFA
    1805         TYPE
     1809        OTYPE
    18061810                { $$ = DeclarationNode::Type; }
    18071811        | DTYPE
     
    18211825        '|' no_attr_identifier_or_type_name '(' type_name_list ')'
    18221826                {
    1823                         typedefTable.openContext( *$2 );
    1824                         $$ = DeclarationNode::newContextUse( $2, $4 );
    1825                 }
    1826         | '|' '{' push context_declaration_list '}'
     1827                        typedefTable.openTrait( *$2 );
     1828                        $$ = DeclarationNode::newTraitUse( $2, $4 );
     1829                }
     1830        | '|' '{' push trait_declaration_list '}'
    18271831                { $$ = $4; }
    1828         | '|' '(' push type_parameter_list pop ')' '{' push context_declaration_list '}' '(' type_name_list ')'
     1832        | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')'
    18291833                { $$ = 0; }
    18301834        ;
     
    18411845
    18421846type_declaring_list:                                                                    // CFA
    1843         TYPE type_declarator
    1844                 { $$ = $2; }
    1845         | storage_class_list TYPE type_declarator
     1847        OTYPE type_declarator
     1848                { $$ = $2; }
     1849        | storage_class_list OTYPE type_declarator
    18461850                { $$ = $3->addQualifiers( $1 ); }
    18471851        | type_declaring_list ',' type_declarator
     
    18691873        ;
    18701874
    1871 context_specifier:                                                                              // CFA
    1872         CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
     1875trait_specifier:                                                                                // CFA
     1876        TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
    18731877                {
    18741878                        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 );
     1879                        $$ = DeclarationNode::newTrait( $2, $5, 0 );
     1880                }
     1881        | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{'
     1882                {
     1883                        typedefTable.enterTrait( *$2 );
    18801884                        typedefTable.enterScope();
    18811885                }
    1882           context_declaration_list '}'
    1883                 {
    1884                         typedefTable.leaveContext();
     1886          trait_declaration_list '}'
     1887                {
     1888                        typedefTable.leaveTrait();
    18851889                        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
     1890                        $$ = DeclarationNode::newTrait( $2, $5, $10 );
     1891                }
     1892        ;
     1893
     1894trait_declaration_list:                                                         // CFA
     1895        trait_declaration
     1896        | trait_declaration_list push trait_declaration
    18931897                { $$ = $1->appendList( $3 ); }
    18941898        ;
    18951899
    1896 context_declaration:                                                                    // CFA
    1897         new_context_declaring_list pop ';'
    1898         | context_declaring_list pop ';'
    1899         ;
    1900 
    1901 new_context_declaring_list:                                                             // CFA
     1900trait_declaration:                                                                      // CFA
     1901        new_trait_declaring_list pop ';'
     1902        | trait_declaring_list pop ';'
     1903        ;
     1904
     1905new_trait_declaring_list:                                                               // CFA
    19021906        new_variable_specifier
    19031907                {
     
    19101914                        $$ = $1;
    19111915                }
    1912         | new_context_declaring_list pop ',' push identifier_or_type_name
     1916        | new_trait_declaring_list pop ',' push identifier_or_type_name
    19131917                {
    19141918                        typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID );
     
    19171921        ;
    19181922
    1919 context_declaring_list:                                                                 // CFA
     1923trait_declaring_list:                                                                   // CFA
    19201924        type_specifier declarator
    19211925                {
     
    19231927                        $$ = $2->addType( $1 );
    19241928                }
    1925         | context_declaring_list pop ',' push declarator
     1929        | trait_declaring_list pop ',' push declarator
    19261930                {
    19271931                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
Note: See TracChangeset for help on using the changeset viewer.