Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r3cfe27f rbd85400  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 24 16:16:16 2016
    13 // Update Count     : 1498
     12// Last Modified On : Mon Feb  1 18:22:42 2016
     13// Update Count     : 1483
    1414//
    1515
     
    5151#include <cstdio>
    5252#include <stack>
     53#include "TypedefTable.h"
    5354#include "lex.h"
    54 #include "parser.h"
    5555#include "ParseNode.h"
    56 #include "TypedefTable.h"
    5756#include "TypeData.h"
    5857#include "LinkageSpec.h"
     
    7574%token FORALL LVALUE                                                                    // CFA
    7675%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    77 %token VALIST                                                                                   // GCC
    7876%token BOOL COMPLEX IMAGINARY                                                   // C99
    7977%token TYPEOF LABEL                                                                             // GCC
    8078%token ENUM STRUCT UNION
    81 %token OTYPE FTYPE DTYPE TRAIT                                          // CFA
     79%token TYPE FTYPE DTYPE CONTEXT                                                 // CFA
    8280%token SIZEOF OFFSETOF
    8381%token ATTRIBUTE EXTENSION                                                              // GCC
     
    173171%type<decl> basic_declaration_specifier basic_type_name basic_type_specifier direct_type_name indirect_type_name
    174172
    175 %type<decl> trait_declaration trait_declaration_list trait_declaring_list trait_specifier
     173%type<decl> context_declaration context_declaration_list context_declaring_list context_specifier
    176174
    177175%type<decl> declaration declaration_list declaration_list_opt declaration_qualifier_list
     
    199197%type<decl> new_array_parameter_1st_dimension
    200198
    201 %type<decl> new_trait_declaring_list new_declaration new_field_declaring_list
     199%type<decl> new_context_declaring_list new_declaration new_field_declaring_list
    202200%type<decl> new_function_declaration new_function_return new_function_specifier
    203201
     
    450448                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::SizeOf ), new TypeValueNode( $3 )); }
    451449        | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')'
    452                 { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); }
     450        { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::OffsetOf ), new TypeValueNode( $3 ), new VarRefNode( $5 )); }
    453451        | ATTR_IDENTIFIER
    454452                { $$ = new CompositeExprNode( new OperatorNode( OperatorNode::Attr ), new VarRefNode( $1 )); }
     
    10221020        | new_function_declaration pop ';'
    10231021        | type_declaring_list pop ';'
    1024         | trait_specifier pop ';'
     1022        | context_specifier pop ';'
    10251023        ;
    10261024
     
    10291027                {
    10301028                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1031                         $$ = $1->addInitializer( $2 );
     1029                        $$ = $1;
    10321030                }
    10331031        | declaration_qualifier_list new_variable_specifier initializer_opt
     
    10361034                {
    10371035                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    1038                         $$ = $2->addQualifiers( $1 )->addInitializer( $3 );;
     1036                        $$ = $2->addQualifiers( $1 );
    10391037                }
    10401038        | new_variable_declaration pop ',' push identifier_or_type_name initializer_opt
    10411039                {
    10421040                        typedefTable.addToEnclosingScope( *$5, TypedefTable::ID );
    1043                         $$ = $1->appendList( $1->cloneType( $5 )->addInitializer( $6 ) );
     1041                        $$ = $1->appendList( $1->cloneType( $5 ) );
    10441042                }
    10451043        ;
     
    13471345        | IMAGINARY                                                                                     // C99
    13481346                { $$ = DeclarationNode::newBasicType( DeclarationNode::Imaginary ); }
    1349         | VALIST                                                                                        // GCC, __builtin_va_list
    1350                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    13511347        ;
    13521348
     
    18071803
    18081804type_class:                                                                                             // CFA
    1809         OTYPE
     1805        TYPE
    18101806                { $$ = DeclarationNode::Type; }
    18111807        | DTYPE
     
    18251821        '|' no_attr_identifier_or_type_name '(' type_name_list ')'
    18261822                {
    1827                         typedefTable.openTrait( *$2 );
    1828                         $$ = DeclarationNode::newTraitUse( $2, $4 );
    1829                 }
    1830         | '|' '{' push trait_declaration_list '}'
     1823                        typedefTable.openContext( *$2 );
     1824                        $$ = DeclarationNode::newContextUse( $2, $4 );
     1825                }
     1826        | '|' '{' push context_declaration_list '}'
    18311827                { $$ = $4; }
    1832         | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_name_list ')'
     1828        | '|' '(' push type_parameter_list pop ')' '{' push context_declaration_list '}' '(' type_name_list ')'
    18331829                { $$ = 0; }
    18341830        ;
     
    18451841
    18461842type_declaring_list:                                                                    // CFA
    1847         OTYPE type_declarator
    1848                 { $$ = $2; }
    1849         | storage_class_list OTYPE type_declarator
     1843        TYPE type_declarator
     1844                { $$ = $2; }
     1845        | storage_class_list TYPE type_declarator
    18501846                { $$ = $3->addQualifiers( $1 ); }
    18511847        | type_declaring_list ',' type_declarator
     
    18731869        ;
    18741870
    1875 trait_specifier:                                                                                // CFA
    1876         TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
     1871context_specifier:                                                                              // CFA
     1872        CONTEXT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}'
    18771873                {
    18781874                        typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
    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 );
     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 );
    18841880                        typedefTable.enterScope();
    18851881                }
    1886           trait_declaration_list '}'
    1887                 {
    1888                         typedefTable.leaveTrait();
     1882          context_declaration_list '}'
     1883                {
     1884                        typedefTable.leaveContext();
    18891885                        typedefTable.addToEnclosingScope( *$2, TypedefTable::ID );
    1890                         $$ = DeclarationNode::newTrait( $2, $5, $10 );
    1891                 }
    1892         ;
    1893 
    1894 trait_declaration_list:                                                         // CFA
    1895         trait_declaration
    1896         | trait_declaration_list push trait_declaration
     1886                        $$ = DeclarationNode::newContext( $2, $5, $10 );
     1887                }
     1888        ;
     1889
     1890context_declaration_list:                                                               // CFA
     1891        context_declaration
     1892        | context_declaration_list push context_declaration
    18971893                { $$ = $1->appendList( $3 ); }
    18981894        ;
    18991895
    1900 trait_declaration:                                                                      // CFA
    1901         new_trait_declaring_list pop ';'
    1902         | trait_declaring_list pop ';'
    1903         ;
    1904 
    1905 new_trait_declaring_list:                                                               // CFA
     1896context_declaration:                                                                    // CFA
     1897        new_context_declaring_list pop ';'
     1898        | context_declaring_list pop ';'
     1899        ;
     1900
     1901new_context_declaring_list:                                                             // CFA
    19061902        new_variable_specifier
    19071903                {
     
    19141910                        $$ = $1;
    19151911                }
    1916         | new_trait_declaring_list pop ',' push identifier_or_type_name
     1912        | new_context_declaring_list pop ',' push identifier_or_type_name
    19171913                {
    19181914                        typedefTable.addToEnclosingScope2( *$5, TypedefTable::ID );
     
    19211917        ;
    19221918
    1923 trait_declaring_list:                                                                   // CFA
     1919context_declaring_list:                                                                 // CFA
    19241920        type_specifier declarator
    19251921                {
     
    19271923                        $$ = $2->addType( $1 );
    19281924                }
    1929         | trait_declaring_list pop ',' push declarator
     1925        | context_declaring_list pop ',' push declarator
    19301926                {
    19311927                        typedefTable.addToEnclosingScope2( TypedefTable::ID );
Note: See TracChangeset for help on using the changeset viewer.