Changeset b826e6b for src/Parser


Ignore:
Timestamp:
Jul 19, 2017, 11:49:33 AM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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:
9cc0472
Parents:
fea3faa (diff), a57cb58 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Parser
Files:
13 edited
3 moved

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rfea3faa rb826e6b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 12:34:05 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 15:46:33 2017
    13 // Update Count     : 1018
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jul 14 16:55:00 2017
     13// Update Count     : 1020
    1414//
    1515
     
    253253        newnode->type->aggregate.fields = fields;
    254254        newnode->type->aggregate.body = body;
     255        newnode->type->aggregate.tagged = false;
     256        newnode->type->aggregate.parent = nullptr;
    255257        return newnode;
    256258} // DeclarationNode::newAggregate
     
    273275        return newnode;
    274276} // DeclarationNode::newEnumConstant
     277
     278DeclarationNode * DeclarationNode::newTreeStruct( Aggregate kind, const string * name, const string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {
     279        assert( name );
     280        DeclarationNode * newnode = new DeclarationNode;
     281        newnode->type = new TypeData( TypeData::Aggregate );
     282        newnode->type->aggregate.kind = kind;
     283        newnode->type->aggregate.name = name;
     284        newnode->type->aggregate.actuals = actuals;
     285        newnode->type->aggregate.fields = fields;
     286        newnode->type->aggregate.body = body;
     287        newnode->type->aggregate.tagged = true;
     288        newnode->type->aggregate.parent = parent;
     289        return newnode;
     290} // DeclarationNode::newTreeStruct
    275291
    276292DeclarationNode * DeclarationNode::newName( string * name ) {
     
    10631079          case TypeData::Enum:
    10641080          case TypeData::Aggregate: {
    1065                   ReferenceToType * ret = buildComAggInst( type, attributes );
     1081                  ReferenceToType * ret = buildComAggInst( type, attributes, linkage );
    10661082                  buildList( type->aggregate.actuals, ret->get_parameters() );
    10671083                  return ret;
  • src/Parser/ExpressionNode.cc

    rfea3faa rb826e6b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:17:07 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 16:44:46 2017
    13 // Update Count     : 541
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Jul 18 10:08:00 2017
     13// Update Count     : 550
    1414//
    1515
     
    2727#include "SynTree/Declaration.h"
    2828#include "Common/UnimplementedError.h"
    29 #include "parseutility.h"
     29#include "parserutility.h"
    3030#include "Common/utility.h"
    3131
     
    4646// type.
    4747
    48 Type::Qualifiers emptyQualifiers;                               // no qualifiers on constants
     48Type::Qualifiers noQualifiers;                          // no qualifiers on constants
    4949
    5050static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
     
    118118        } // if
    119119
    120         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[Unsigned][size] ), str, v ) );
     120        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
    121121        delete &str;                                                                            // created by lex
    122122        return ret;
     
    153153        } // if
    154154
    155         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, kind[complx][size] ), str, v ) );
     155        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][size] ), str, v ) );
    156156        delete &str;                                                                            // created by lex
    157157        return ret;
     
    159159
    160160Expression *build_constantChar( const std::string & str ) {
    161         Expression * ret = new ConstantExpr( Constant( new BasicType( emptyQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
     161        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
    162162        delete &str;                                                                            // created by lex
    163163        return ret;
     
    166166ConstantExpr *build_constantStr( const std::string & str ) {
    167167        // string should probably be a primitive type
    168         ArrayType *at = new ArrayType( emptyQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
     168        ArrayType *at = new ArrayType( noQualifiers, new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ),
    169169                                                                   new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ),  // +1 for '\0' and -2 for '"'
    170170                                                                   false, false );
     
    176176
    177177Expression *build_constantZeroOne( const std::string & str ) {
    178         Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( emptyQualifiers ) : (Type*)new OneType( emptyQualifiers ), str,
     178        Expression * ret = new ConstantExpr( Constant( str == "0" ? (Type *)new ZeroType( noQualifiers ) : (Type*)new OneType( noQualifiers ), str,
    179179                                                                                                   str == "0" ? (unsigned long long int)0 : (unsigned long long int)1 ) );
    180180        delete &str;                                                                            // created by lex
     
    231231}
    232232
     233// Must harmonize with OperKinds.
    233234static const char *OperName[] = {
    234235        // diadic
    235         "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
     236        "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
    236237        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    237         "?=?", "?@=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
     238        "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
    238239        "?[?]", "...",
    239240        // monadic
  • src/Parser/InitializerNode.cc

    rfea3faa rb826e6b  
    7474
    7575        InitializerNode *moreInit;
    76         if  ( get_next() != 0 && ((moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) != 0) )
     76        if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) {
    7777                moreInit->printOneLine( os );
     78        }
    7879}
    7980
    8081Initializer *InitializerNode::build() const {
    8182        if ( aggregate ) {
     83                // steal designators from children
     84                std::list< Designation * > designlist;
     85                InitializerNode * child = next_init();
     86                for ( ; child != nullptr; child = dynamic_cast< InitializerNode * >( child->get_next() ) ) {
     87                        std::list< Expression * > desList;
     88                        buildList< Expression, ExpressionNode >( child->designator, desList );
     89                        designlist.push_back( new Designation( desList ) );
     90                } // for
    8291                std::list< Initializer * > initlist;
    8392                buildList< Initializer, InitializerNode >( next_init(), initlist );
    84 
    85                 std::list< Expression * > designlist;
    86 
    87                 if ( designator != 0 ) {
    88                         buildList< Expression, ExpressionNode >( designator, designlist );
    89                 } // if
    90 
    9193                return new ListInit( initlist, designlist, maybeConstructed );
    9294        } else {
    93                 std::list< Expression * > designators;
    94 
    95                 if ( designator != 0 )
    96                         buildList< Expression, ExpressionNode >( designator, designators );
    97 
    98                 if ( get_expression() != 0)
    99                         return new SingleInit( maybeBuild< Expression >( get_expression() ), designators, maybeConstructed );
     95                if ( get_expression() != 0) {
     96                        return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed );
     97                }
    10098        } // if
    101 
    10299        return 0;
    103100}
  • src/Parser/LinkageSpec.cc

    rfea3faa rb826e6b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:22:09 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct  2 23:16:21 2016
    13 // Update Count     : 23
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jul  7 11:11:00 2017
     13// Update Count     : 25
    1414//
    1515
     
    2222#include "Common/SemanticError.h"
    2323
    24 LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) {
     24namespace LinkageSpec {
     25
     26Spec linkageCheck( const string * spec ) {
     27        assert( spec );
    2528        unique_ptr<const string> guard( spec ); // allocated by lexer
    2629        if ( *spec == "\"Cforall\"" ) {
     
    2831        } else if ( *spec == "\"C\"" ) {
    2932                return C;
     33        } else if ( *spec == "\"BuiltinC\"" ) {
     34                return BuiltinC;
    3035        } else {
    3136                throw SemanticError( "Invalid linkage specifier " + *spec );
     
    3338}
    3439
    35 string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) {
    36         assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
    37         static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
    38                 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in",
    39         };
    40         return linkageKinds[linkage];
     40Spec linkageUpdate( Spec old_spec, const string * cmd ) {
     41        assert( cmd );
     42        unique_ptr<const string> guard( cmd ); // allocated by lexer
     43        if ( *cmd == "\"Cforall\"" ) {
     44                old_spec.is_mangled = true;
     45                return old_spec;
     46        } else if ( *cmd == "\"C\"" ) {
     47                old_spec.is_mangled = false;
     48                return old_spec;
     49        } else {
     50                throw SemanticError( "Invalid linkage specifier " + *cmd );
     51        } // if
    4152}
    4253
    43 bool LinkageSpec::isDecoratable( Spec spec ) {
    44         assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    45         static bool decoratable[LinkageSpec::NoOfSpecs] = {
    46                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
    47                         true,           true,           false,  true,           false,
    48         };
    49         return decoratable[spec];
     54std::string linkageName( Spec linkage ) {
     55    switch ( linkage ) {
     56    case Intrinsic:
     57        return "intrinsic";
     58    case C:
     59        return "C";
     60    case Cforall:
     61        return "Cforall";
     62    case AutoGen:
     63        return "autogenerated cfa";
     64    case Compiler:
     65        return "compiler built-in";
     66    case BuiltinCFA:
     67        return "cfa built-in";
     68    case BuiltinC:
     69        return "c built-in";
     70    default:
     71        return "<unnamed linkage spec>";
     72    }
    5073}
    5174
    52 bool LinkageSpec::isGeneratable( Spec spec ) {
    53         assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    54         static bool generatable[LinkageSpec::NoOfSpecs] = {
    55                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
    56                         true,           true,           true,   true,           false,
    57         };
    58         return generatable[spec];
    59 }
    60 
    61 bool LinkageSpec::isOverridable( Spec spec ) {
    62         assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
    63         static bool overridable[LinkageSpec::NoOfSpecs] = {
    64                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
    65                         true,           false,          false,  true,           false,
    66         };
    67         return overridable[spec];
    68 }
    69 
    70 bool LinkageSpec::isBuiltin( Spec spec ) {
    71         assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
    72         static bool builtin[LinkageSpec::NoOfSpecs] = {
    73                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler
    74                         true,           false,          false,  false,          true,
    75         };
    76         return builtin[spec];
    77 }
     75} // LinkageSpec
    7876
    7977// Local Variables: //
  • src/Parser/LinkageSpec.h

    rfea3faa rb826e6b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // LinkageSpec.h -- 
     7// LinkageSpec.h --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Oct  1 23:03:17 2016
    13 // Update Count     : 11
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jul  7 11:03:00 2017
     13// Update Count     : 13
    1414//
    1515
     
    1919#include <string>
    2020
    21 struct LinkageSpec {
    22         enum Spec {
    23                 Intrinsic,                                                                              // C built-in defined in prelude
    24                 Cforall,                                                                                // ordinary
    25                 C,                                                                                              // not overloadable, not mangled
    26                 AutoGen,                                                                                // built by translator (struct assignment)
    27                 Compiler,                                                                               // gcc internal
    28                 NoOfSpecs
     21namespace LinkageSpec {
     22        // All linkage specs are some combination of these flags:
     23        enum {
     24                Mangle = 1 << 0,
     25                Generate = 1 << 1,
     26                Overrideable = 1 << 2,
     27                Builtin = 1 << 3,
     28
     29                NoOfSpecs = 1 << 4,
    2930        };
    30  
    31         static Spec linkageCheck( const std::string * );
    32         static std::string linkageName( Spec );
    33  
    34         static bool isDecoratable( Spec );
    35         static bool isGeneratable( Spec );
    36         static bool isOverridable( Spec );
    37         static bool isBuiltin( Spec );
     31
     32        union Spec {
     33                unsigned int val;
     34                struct {
     35                        bool is_mangled : 1;
     36                        bool is_generatable : 1;
     37                        bool is_overridable : 1;
     38                        bool is_builtin : 1;
     39                };
     40                constexpr Spec( unsigned int val ) : val( val ) {}
     41                constexpr Spec( Spec const &other ) : val( other.val ) {}
     42                // Operators may go here.
     43                // Supports == and !=
     44                constexpr operator unsigned int () const { return val; }
     45        };
     46
     47
     48        Spec linkageCheck( const std::string * );
     49        // Returns the Spec with the given name (limited to C, Cforall & BuiltinC)
     50        Spec linkageUpdate( Spec old_spec, const std::string * cmd );
     51        /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
     52         * If cmd = "Cforall" returns old_spec Spec with is_mangled = true
     53         */
     54
     55        std::string linkageName( Spec );
     56
     57        // To Update: LinkageSpec::isXyz( cur_spec ) -> cur_spec.is_xyz
     58        inline bool isMangled( Spec spec ) { return spec.is_mangled; }
     59        inline bool isGeneratable( Spec spec ) { return spec.is_generatable; }
     60        inline bool isOverridable( Spec spec ) { return spec.is_overridable; }
     61        inline bool isBuiltin( Spec spec ) { return spec.is_builtin; }
     62
     63        // Pre-defined flag combinations:
     64        // C built-in defined in prelude
     65        constexpr Spec const Intrinsic = { Mangle | Generate | Overrideable | Builtin };
     66        // ordinary
     67        constexpr Spec const Cforall = { Mangle | Generate };
     68        // not overloadable, not mangled
     69        constexpr Spec const C = { Generate };
     70        // built by translator (struct assignment)
     71        constexpr Spec const AutoGen = { Mangle | Generate | Overrideable };
     72        // gcc internal
     73        constexpr Spec const Compiler = { Builtin };
     74        // mangled builtins
     75        constexpr Spec const BuiltinCFA = { Mangle | Generate | Builtin };
     76        // non-mangled builtins
     77        constexpr Spec const BuiltinC = { Generate | Builtin };
    3878};
    3979
  • src/Parser/ParseNode.h

    rfea3faa rb826e6b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jun 12 13:00:00 2017
    13 // Update Count     : 779
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 15 16:00:48 2017
     13// Update Count     : 785
    1414//
    1515
     
    141141};
    142142
     143// Must harmonize with OperName.
    143144enum class OperKinds {
    144145        // diadic
    145         SizeOf, AlignOf, OffsetOf, Plus, Minus, Mul, Div, Mod, Or, And,
     146        SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,
    146147        BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    147         Assign, AtAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
     148        Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
    148149        Index, Range,
    149150        // monadic
     
    248249        static DeclarationNode * newAsmStmt( StatementNode * stmt ); // gcc external asm statement
    249250
     251        // Perhaps this would best fold into newAggragate.
     252        static DeclarationNode * newTreeStruct( Aggregate kind, const std::string * name, const std::string * parent, ExpressionNode * actuals, DeclarationNode * fields, bool body );
     253
    250254        DeclarationNode();
    251255        ~DeclarationNode();
     
    332336
    333337        static UniqueName anonymous;
     338
     339        // Temp to test TreeStruct
     340        const std::string * parent_name;
    334341}; // DeclarationNode
    335342
  • src/Parser/ParserTypes.h

    rfea3faa rb826e6b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // lex.h --
     7// parser.hh --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep 22 08:58:10 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug 21 11:28:47 2016
    13 // Update Count     : 347
     12// Last Modified On : Wed Jun 28 22:10:17 2017
     13// Update Count     : 349
    1414//
    1515
    16 #ifndef PARSER_LEX_H
    17 #define PARSER_LEX_H
     16#ifndef PARSER_HH
     17#define PARSER_HH
    1818
    1919int yylex();
     
    4242}; // Token
    4343
    44 #endif // PARSER_LEX_H
     44#endif // PARSER_HH
    4545
    4646// Local Variables: //
  • src/Parser/StatementNode.cc

    rfea3faa rb826e6b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 14:59:41 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jun 12 13:03:00 2017
    13 // Update Count     : 329
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Jul 11 21:23:15 2017
     13// Update Count     : 331
    1414//
    1515
     
    2121#include "SynTree/Statement.h"
    2222#include "SynTree/Expression.h"
    23 #include "parseutility.h"
     23#include "parserutility.h"
    2424#include "Common/utility.h"
    2525
     
    9393        std::list< Statement * > branches;
    9494        buildMoveList< Statement, StatementNode >( stmt, branches );
    95         assert( branches.size() >= 0 );                                         // size == 0 for switch (...) {}, i.e., no declaration or statements
     95        // branches.size() == 0 for switch (...) {}, i.e., no declaration or statements
    9696        return new SwitchStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches );
    9797}
  • src/Parser/TypeData.cc

    rfea3faa rb826e6b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 15:52:43 2017
    13 // Update Count     : 563
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Jul 18 10:10:00 2017
     13// Update Count     : 566
    1414//
    1515
     
    6363                aggregate.fields = nullptr;
    6464                aggregate.body = false;
     65                aggregate.tagged = false;
     66                aggregate.parent = nullptr;
    6567                break;
    6668          case AggregateInst:
     
    121123                delete aggregate.actuals;
    122124                delete aggregate.fields;
     125                delete aggregate.parent;
    123126                // delete aggregate;
    124127                break;
     
    192195                newtype->aggregate.kind = aggregate.kind;
    193196                newtype->aggregate.body = aggregate.body;
     197                newtype->aggregate.tagged = aggregate.tagged;
     198                newtype->aggregate.parent = aggregate.parent ? new string( *aggregate.parent ) : nullptr;
    194199                break;
    195200          case AggregateInst:
     
    449454          case TypeData::Builtin:
    450455                if(td->builtintype == DeclarationNode::Zero) {
    451                         return new ZeroType( emptyQualifiers );
     456                        return new ZeroType( noQualifiers );
    452457                }
    453458                else if(td->builtintype == DeclarationNode::One) {
    454                         return new OneType( emptyQualifiers );
     459                        return new OneType( noQualifiers );
    455460                }
    456461                else {
     
    614619} // buildPointer
    615620
    616 AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes ) {
     621AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
    617622        assert( td->kind == TypeData::Aggregate );
    618623        AggregateDecl * at;
    619624        switch ( td->aggregate.kind ) {
    620625          case DeclarationNode::Struct:
     626                if ( td->aggregate.tagged ) {
     627                        at = new StructDecl( *td->aggregate.name, td->aggregate.parent, attributes, linkage );
     628                        buildForall( td->aggregate.params, at->get_parameters() );
     629                        break;
     630                }
    621631          case DeclarationNode::Coroutine:
    622632          case DeclarationNode::Monitor:
    623633          case DeclarationNode::Thread:
    624                 at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes );
     634                at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage );
    625635                buildForall( td->aggregate.params, at->get_parameters() );
    626636                break;
     
    643653} // buildAggregate
    644654
    645 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes ) {
     655ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
    646656        switch ( type->kind ) {
    647657          case TypeData::Enum: {
     
    656666                  ReferenceToType * ret;
    657667                  if ( type->aggregate.body ) {
    658                           AggregateDecl * typedecl = buildAggregate( type, attributes );
     668                          AggregateDecl * typedecl = buildAggregate( type, attributes, linkage );
    659669                          switch ( type->aggregate.kind ) {
    660670                                case DeclarationNode::Struct:
     
    760770                if ( cur->has_enumeratorValue() ) {
    761771                        ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members);
    762                         member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ), list< Expression * >() ) );
     772                        member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) );
    763773                } // if
    764774        } // for
     
    777787TupleType * buildTuple( const TypeData * td ) {
    778788        assert( td->kind == TypeData::Tuple );
    779         TupleType * ret = new TupleType( buildQualifiers( td ) );
    780         buildTypeList( td->tuple, ret->get_types() );
     789        std::list< Type * > types;
     790        buildTypeList( td->tuple, types );
     791        TupleType * ret = new TupleType( buildQualifiers( td ), types );
    781792        buildForall( td->forall, ret->get_forall() );
    782793        return ret;
     
    802813                return decl->set_asmName( asmName );
    803814        } else if ( td->kind == TypeData::Aggregate ) {
    804                 return buildAggregate( td, attributes );
     815                return buildAggregate( td, attributes, linkage );
    805816        } else if ( td->kind == TypeData::Enum ) {
    806817                return buildEnum( td, attributes );
  • src/Parser/TypeData.h

    rfea3faa rb826e6b  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:18:36 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 16 08:32:39 2017
    13 // Update Count     : 185
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Jul 14 16:57:00 2017
     13// Update Count     : 187
    1414//
    1515
     
    3131                DeclarationNode * fields;
    3232                bool body;
     33
     34                bool tagged;
     35                const std::string * parent;
    3336        };
    3437
     
    102105ArrayType * buildArray( const TypeData * );
    103106AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > );
    104 ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes );
     107ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage );
    105108ReferenceToType * buildAggInst( const TypeData * );
    106109TypeDecl * buildVariable( const TypeData * );
  • src/Parser/TypedefTable.h

    rfea3faa rb826e6b  
    1010// Created On       : Sat May 16 15:24:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 15 18:25:04 2016
    13 // Update Count     : 28
     12// Last Modified On : Wed Jun 28 21:56:34 2017
     13// Update Count     : 33
    1414//
    1515
     
    2222#include <stack>
    2323
    24 #include "lex.h"
    25 #include "parser.h"
     24#include "ParserTypes.h"
     25#include "parser.hh"
    2626
    2727class TypedefTable {
  • src/Parser/lex.ll

    rfea3faa rb826e6b  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Tue May 30 22:00:48 2017
    13  * Update Count     : 527
     12 * Last Modified On : Tue Jul 18 07:11:48 2017
     13 * Update Count     : 544
    1414 */
    1515
     
    2727#include <cstdio>                                                                               // FILENAME_MAX
    2828
    29 #include "lex.h"
    30 #include "parser.h"                                                                             // YACC generated definitions based on C++ grammar
    3129#include "ParseNode.h"
    3230#include "TypedefTable.h"
     
    6159}
    6260
     61// Stop warning due to incorrectly generated flex code.
     62#pragma GCC diagnostic ignored "-Wsign-compare"
    6363%}
    6464
     
    125125op_unary {op_unary_only}|{op_unary_binary}|{op_unary_pre_post}
    126126
    127 op_binary_only "/"|"%"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"&="|"|="|"^="|"<<="|">>="
     127op_binary_only "/"|"%"|"\\"|"^"|"&"|"|"|"<"|">"|"="|"=="|"!="|"<<"|">>"|"<="|">="|"+="|"-="|"*="|"/="|"%="|"\\="|"&="|"|="|"^="|"<<="|">>="
    128128op_binary_over {op_unary_binary}|{op_binary_only}
    129129                                // op_binary_not_over "?"|"->"|"."|"&&"|"||"|"@="
     
    136136
    137137%%
    138                                    /* line directives */
     138                                /* line directives */
    139139^{h_white}*"#"{h_white}*[0-9]+{h_white}*["][^"\n]+["].*"\n" {
    140140        /* " stop highlighting */
     
    232232int                             { KEYWORD_RETURN(INT); }
    233233__int128                { KEYWORD_RETURN(INT); }                                // GCC
     234__int128_t              { KEYWORD_RETURN(INT); }                                // GCC
    234235__label__               { KEYWORD_RETURN(LABEL); }                              // GCC
    235236long                    { KEYWORD_RETURN(LONG); }
     
    266267__typeof                { KEYWORD_RETURN(TYPEOF); }                             // GCC
    267268__typeof__              { KEYWORD_RETURN(TYPEOF); }                             // GCC
     269__uint128_t             { KEYWORD_RETURN(INT); }                                // GCC
    268270union                   { KEYWORD_RETURN(UNION); }
    269271unsigned                { KEYWORD_RETURN(UNSIGNED); }
     
    274276__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    275277while                   { KEYWORD_RETURN(WHILE); }
     278with                    { KEYWORD_RETURN(WITH); }                               // CFA
    276279zero_t                  { NUMERIC_RETURN(ZERO_T); }                             // CFA
    277280
     
    336339"-"                             { ASCIIOP_RETURN(); }
    337340"*"                             { ASCIIOP_RETURN(); }
     341"\\"                    { ASCIIOP_RETURN(); }                                   // CFA, exponentiation
    338342"/"                             { ASCIIOP_RETURN(); }
    339343"%"                             { ASCIIOP_RETURN(); }
     
    360364"+="                    { NAMEDOP_RETURN(PLUSassign); }
    361365"-="                    { NAMEDOP_RETURN(MINUSassign); }
     366"\\="                   { NAMEDOP_RETURN(EXPassign); }                  // CFA, exponentiation
    362367"*="                    { NAMEDOP_RETURN(MULTassign); }
    363368"/="                    { NAMEDOP_RETURN(DIVassign); }
  • src/Parser/module.mk

    rfea3faa rb826e6b  
    1111## Created On       : Sat May 16 15:29:09 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Tue Aug 16 17:28:34 2016
    14 ## Update Count     : 101
     13## Last Modified On : Wed Jun 28 21:58:29 2017
     14## Update Count     : 104
    1515###############################################################################
    1616
    17 BUILT_SOURCES = Parser/parser.h
     17BUILT_SOURCES = Parser/parser.hh
    1818
    1919AM_YFLAGS = -d -t -v
     
    2929       Parser/TypeData.cc \
    3030       Parser/LinkageSpec.cc \
    31        Parser/parseutility.cc
     31       Parser/parserutility.cc
    3232
    3333MAINTAINERCLEANFILES += Parser/parser.output
  • src/Parser/parser.yy

    rfea3faa rb826e6b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // cfa.y --
     7// parser.yy --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 12 12:59:00 2017
    13 // Update Count     : 2402
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Mon Jul 17 12:17:00 2017
     13// Update Count     : 2455
    1414//
    1515
     
    4848#include <cstdio>
    4949#include <stack>
    50 #include "lex.h"
    51 #include "parser.h"
    5250#include "ParseNode.h"
    5351#include "TypedefTable.h"
     
    8886bool forall = false;                                                                    // aggregate have one or more forall qualifiers ?
    8987%}
     88
     89// Types declaration
     90%union
     91{
     92        Token tok;
     93        ParseNode * pn;
     94        ExpressionNode * en;
     95        DeclarationNode * decl;
     96        DeclarationNode::Aggregate aggKey;
     97        DeclarationNode::TypeClass tclass;
     98        StatementNode * sn;
     99        ConstantExpr * constant;
     100        ForCtl * fctl;
     101        LabelNode * label;
     102        InitializerNode * in;
     103        OperKinds op;
     104        std::string * str;
     105        bool flag;
     106        CatchStmt::Kind catch_kind;
     107}
    90108
    91109//************************* TERMINAL TOKENS ********************************
     
    111129%token ATTRIBUTE EXTENSION                                                              // GCC
    112130%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    113 %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
    114132%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    115133%token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
     
    133151%token ELLIPSIS                                                                                 // ...
    134152
    135 %token MULTassign       DIVassign       MODassign                               // *=   /=      %=/
     153%token EXPassign        MULTassign      DIVassign       MODassign       // \=   *=      /=      %=
    136154%token PLUSassign       MINUSassign                                                     // +=   -=
    137155%token LSassign         RSassign                                                        // <<=  >>=
     
    139157
    140158%token ATassign                                                                                 // @=
    141 
    142 // Types declaration
    143 %union
    144 {
    145         Token tok;
    146         ParseNode * pn;
    147         ExpressionNode * en;
    148         DeclarationNode * decl;
    149         DeclarationNode::Aggregate aggKey;
    150         DeclarationNode::TypeClass tclass;
    151         StatementNode * sn;
    152         ConstantExpr * constant;
    153         ForCtl * fctl;
    154         LabelNode * label;
    155         InitializerNode * in;
    156         OperKinds op;
    157         std::string * str;
    158         bool flag;
    159 }
    160159
    161160%type<tok> identifier  no_attr_identifier  zero_one
     
    169168%type<op> ptrref_operator                               unary_operator                          assignment_operator
    170169%type<en> primary_expression                    postfix_expression                      unary_expression
    171 %type<en> cast_expression                               multiplicative_expression       additive_expression                     shift_expression
    172 %type<en> relational_expression                 equality_expression                     AND_expression                          exclusive_OR_expression
    173 %type<en> inclusive_OR_expression               logical_AND_expression          logical_OR_expression           conditional_expression
    174 %type<en> constant_expression                   assignment_expression           assignment_expression_opt
     170%type<en> cast_expression                               exponential_expression          multiplicative_expression       additive_expression
     171%type<en> shift_expression                              relational_expression           equality_expression
     172%type<en> AND_expression                                exclusive_OR_expression         inclusive_OR_expression
     173%type<en> logical_AND_expression                logical_OR_expression
     174%type<en> conditional_expression                constant_expression                     assignment_expression           assignment_expression_opt
    175175%type<en> comma_expression                              comma_expression_opt
    176 %type<en> argument_expression_list              argument_expression                     assignment_opt
     176%type<en> argument_expression_list              argument_expression                     default_initialize_opt
    177177%type<fctl> for_control_expression
    178178%type<en> subrange
     
    185185// statements
    186186%type<sn> labeled_statement                             compound_statement                      expression_statement            selection_statement
    187 %type<sn> iteration_statement                   jump_statement                          exception_statement                     asm_statement
     187%type<sn> iteration_statement                   jump_statement
     188%type<sn> with_statement                                exception_statement                     asm_statement
    188189%type<sn> fall_through_opt                              fall_through
    189190%type<sn> statement                                             statement_list
    190191%type<sn> block_item_list                               block_item
    191 %type<sn> case_clause
     192%type<sn> with_clause_opt
    192193%type<en> case_value
    193 %type<sn> case_value_list                               case_label                                      case_label_list
     194%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    194195%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    195196%type<sn> /* handler_list */                    handler_clause                          finally_clause
     197%type<catch_kind> handler_key
    196198
    197199// declarations
     
    572574        ;
    573575
     576exponential_expression:
     577        cast_expression
     578        | exponential_expression '\\' cast_expression
     579                { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); }
     580        ;
     581
    574582multiplicative_expression:
    575         cast_expression
    576         | multiplicative_expression '*' cast_expression
     583        exponential_expression
     584        | multiplicative_expression '*' exponential_expression
    577585                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }
    578         | multiplicative_expression '/' cast_expression
     586        | multiplicative_expression '/' exponential_expression
    579587                { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }
    580         | multiplicative_expression '%' cast_expression
     588        | multiplicative_expression '%' exponential_expression
    581589                { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }
    582590        ;
     
    677685        '='                                                                                     { $$ = OperKinds::Assign; }
    678686        | ATassign                                                                      { $$ = OperKinds::AtAssn; }
     687        | EXPassign                                                                     { $$ = OperKinds::ExpAssn; }
    679688        | MULTassign                                                            { $$ = OperKinds::MulAssn; }
    680689        | DIVassign                                                                     { $$ = OperKinds::DivAssn; }
     
    729738        | iteration_statement
    730739        | jump_statement
     740        | with_statement
    731741        | exception_statement
    732742        | asm_statement
     
    936946        ;
    937947
     948with_statement:
     949        WITH '(' tuple_expression_list ')' compound_statement
     950                { $$ = (StatementNode *)0; }                                    // FIX ME
     951        ;
     952
    938953exception_statement:
    939954        TRY compound_statement handler_clause
     
    959974
    960975handler_clause:
    961         CATCH '(' push push exception_declaration pop ')' compound_statement pop
    962                 { $$ = new StatementNode( build_catch( CatchStmt::Terminate, $5, nullptr, $8 ) ); }
    963         | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    964                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Terminate, $6, nullptr, $9 ) ) ); }
    965         | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    966                 { $$ = new StatementNode( build_catch( CatchStmt::Resume, $5, nullptr, $8 ) ); }
    967         | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    968                 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( CatchStmt::Resume, $6, nullptr, $9 ) ) ); }
     976        // TEMPORARY, TEST EXCEPTIONS
     977        handler_key '(' push push INTEGERconstant pop ')' compound_statement pop
     978                { $$ = new StatementNode( build_catch( $1, nullptr, new ExpressionNode( build_constantInteger( *$5 ) ), $8 ) ); }
     979        | handler_clause handler_key '(' push push INTEGERconstant pop ')' compound_statement pop
     980                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); }
     981
     982        | handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     983                { $$ = new StatementNode( build_catch( $1, $5, nullptr, $9 ) ); }
     984        | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop
     985                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $10 ) ) ); }
     986        ;
     987
     988handler_predicate_opt:
     989        //empty
     990        | ';' conditional_expression
     991        ;
     992
     993handler_key:
     994        CATCH
     995                { $$ = CatchStmt::Terminate; }
     996        | CATCHRESUME
     997                { $$ = CatchStmt::Resume; }
    969998        ;
    970999
     
    16511680        | aggregate_key attribute_list_opt typegen_name         // CFA
    16521681                { $$ = $3->addQualifiers( $2 ); }
     1682
     1683// Temp, testing TreeStruct
     1684    | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name
     1685        {
     1686            typedefTable.makeTypedef( *$4 );            // create typedef
     1687            if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $
     1688            forall = false;                             // reset
     1689        }
     1690      '{' field_declaration_list '}'
     1691        {
     1692            $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,
     1693                $4, nullptr, nullptr, $7, true )->addQualifiers( $3 );
     1694        }
     1695    | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name TYPEDEFname
     1696        {
     1697            typedefTable.makeTypedef( *$4 );            // create typedef
     1698            if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $
     1699            forall = false;                             // reset
     1700        }
     1701      '{' field_declaration_list '}'
     1702        {
     1703            $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,
     1704                $4, $5, nullptr, $8, true )->addQualifiers( $3 );
     1705        }
    16531706        ;
    16541707
     
    18291882cfa_parameter_declaration:                                                              // CFA, new & old style parameter declaration
    18301883        parameter_declaration
    1831         | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt
     1884        | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt
    18321885                { $$ = $1->addName( $2 ); }
    1833         | cfa_abstract_tuple identifier_or_type_name assignment_opt
     1886        | cfa_abstract_tuple identifier_or_type_name default_initialize_opt
    18341887                // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator).
    18351888                { $$ = $1->addName( $2 ); }
    1836         | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt
     1889        | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt
    18371890                { $$ = $2->addName( $3 )->addQualifiers( $1 ); }
    18381891        | cfa_function_specifier
     
    18511904parameter_declaration:
    18521905                // No SUE declaration in parameter list.
    1853         declaration_specifier_nobody identifier_parameter_declarator assignment_opt
     1906        declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt
    18541907                {
    18551908                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    18561909                        $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr );
    18571910                }
    1858         | declaration_specifier_nobody type_parameter_redeclarator assignment_opt
     1911        | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt
    18591912                {
    18601913                        typedefTable.addToEnclosingScope( TypedefTable::ID );
     
    18641917
    18651918abstract_parameter_declaration:
    1866         declaration_specifier_nobody assignment_opt
     1919        declaration_specifier_nobody default_initialize_opt
    18671920                { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); }
    1868         | declaration_specifier_nobody abstract_parameter_declarator assignment_opt
     1921        | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt
    18691922                { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); }
    18701923        ;
     
    21672220                {
    21682221                        linkageStack.push( linkage );                           // handle nested extern "C"/"Cforall"
    2169                         linkage = LinkageSpec::linkageCheck( $2 );
     2222                        linkage = LinkageSpec::linkageUpdate( linkage, $2 );
    21702223                }
    21712224          '{' external_definition_list_opt '}'
     
    22032256        ;
    22042257
     2258with_clause_opt:
     2259        // empty
     2260                { $$ = (StatementNode *)0; }                                    // FIX ME
     2261        | WITH '(' tuple_expression_list ')'
     2262                { $$ = (StatementNode *)0; }                                    // FIX ME
     2263        ;
     2264
    22052265function_definition:
    2206         cfa_function_declaration compound_statement                     // CFA
     2266        cfa_function_declaration with_clause_opt compound_statement     // CFA
    22072267                {
    22082268                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22092269                        typedefTable.leaveScope();
    2210                         $$ = $1->addFunctionBody( $2 );
    2211                 }
    2212         | declaration_specifier function_declarator compound_statement
     2270                        $$ = $1->addFunctionBody( $3 );
     2271                }
     2272        | declaration_specifier function_declarator with_clause_opt compound_statement
    22132273                {
    22142274                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22152275                        typedefTable.leaveScope();
    2216                         $$ = $2->addFunctionBody( $3 )->addType( $1 );
    2217                 }
    2218         | type_qualifier_list function_declarator compound_statement
     2276                        $$ = $2->addFunctionBody( $4 )->addType( $1 );
     2277                }
     2278        | type_qualifier_list function_declarator with_clause_opt compound_statement
    22192279                {
    22202280                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22212281                        typedefTable.leaveScope();
    2222                         $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
    2223                 }
    2224         | declaration_qualifier_list function_declarator compound_statement
     2282                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
     2283                }
     2284        | declaration_qualifier_list function_declarator with_clause_opt compound_statement
    22252285                {
    22262286                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22272287                        typedefTable.leaveScope();
    2228                         $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
    2229                 }
    2230         | declaration_qualifier_list type_qualifier_list function_declarator compound_statement
     2288                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
     2289                }
     2290        | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
    22312291                {
    22322292                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22332293                        typedefTable.leaveScope();
    2234                         $$ = $3->addFunctionBody( $4 )->addQualifiers( $2 )->addQualifiers( $1 );
     2294                        $$ = $3->addFunctionBody( $5 )->addQualifiers( $2 )->addQualifiers( $1 );
    22352295                }
    22362296
    22372297                // Old-style K&R function definition, OBSOLESCENT (see 4)
    2238         | declaration_specifier KR_function_declarator push KR_declaration_list_opt compound_statement
     2298        | declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22392299                {
    22402300                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22412301                        typedefTable.leaveScope();
    2242                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addType( $1 );
    2243                 }
    2244         | type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2302                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addType( $1 );
     2303                }
     2304        | type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22452305                {
    22462306                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22472307                        typedefTable.leaveScope();
    2248                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
     2308                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
    22492309                }
    22502310
    22512311                // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4)
    2252         | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2312        | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22532313                {
    22542314                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22552315                        typedefTable.leaveScope();
    2256                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
    2257                 }
    2258         | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2316                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
     2317                }
     2318        | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22592319                {
    22602320                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22612321                        typedefTable.leaveScope();
    2262                         $$ = $3->addOldDeclList( $5 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 );
     2322                        $$ = $3->addOldDeclList( $5 )->addFunctionBody( $7 )->addQualifiers( $2 )->addQualifiers( $1 );
    22632323                }
    22642324        ;
     
    23232383        | TYPEGENname
    23242384        | CONST
    2325                 { $$ = Token{ new string( "__const__" ) }; }
     2385                { $$ = Token{ new string( "__const__" ), { nullptr, -1 } }; }
    23262386        ;
    23272387
     
    30223082        ;
    30233083
    3024 assignment_opt:
     3084default_initialize_opt:
    30253085        // empty
    30263086                { $$ = nullptr; }
  • src/Parser/parserutility.cc

    rfea3faa rb826e6b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // parseutility.cc --
     7// parserutility.cc --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:30:39 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 15:33:41 2017
    13 // Update Count     : 5
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Jul 18 10:12:00 2017
     13// Update Count     : 8
    1414//
    1515
    16 #include "parseutility.h"
     16#include "parserutility.h"
    1717#include "SynTree/Type.h"
    1818#include "SynTree/Expression.h"
     
    2626        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    2727        comparison->get_args().push_back( orig );
    28         comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( emptyQualifiers ), "0", (unsigned long long int)0 ) ) );
     28        comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( noQualifiers ), "0", (unsigned long long int)0 ) ) );
    2929        return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    3030}
  • src/Parser/parserutility.h

    rfea3faa rb826e6b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // parseutility.h --
     7// parserutility.h --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:31:46 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 16 15:32:58 2015
    13 // Update Count     : 2
     12// Last Modified On : Wed Jun 28 22:11:40 2017
     13// Update Count     : 3
    1414//
    1515
Note: See TracChangeset for help on using the changeset viewer.