Changes in / [95487027:a43c561]


Ignore:
Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Common/SemanticError.cc

    r95487027 ra43c561  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  7 08:05:26 2018
    13 // Update Count     : 10
     12// Last Modified On : Wed May 16 15:01:20 2018
     13// Update Count     : 9
    1414//
    1515
     
    9797void SemanticError( CodeLocation location, std::string error ) {
    9898        SemanticErrorThrow = true;
    99         throw SemanticErrorException( location, error );
     99        throw SemanticErrorException(location, error);
    100100}
    101101
  • src/Parser/DeclarationNode.cc

    r95487027 ra43c561  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  7 12:08:55 2018
    13 // Update Count     : 1079
     12// Last Modified On : Wed Jun  6 15:57:50 2018
     13// Update Count     : 1076
    1414//
    1515
     
    545545                                        type->aggregate.params->appendList( q->type->forall ); // augment forall qualifier
    546546                                } else {                                                                // not polymorphic
    547                                         type->aggregate.params = q->type->forall; // set forall qualifier
     547                                        type->aggregate.params = q->type->forall; // make polymorphic type
     548                                        // change implicit typedef from TYPEDEFname to TYPEGENname
     549                                        typedefTable.changeKind( *type->aggregate.name, TYPEGENname );
    548550                                } // if
    549551                        } else {                                                                        // not polymorphic
  • src/Parser/TypedefTable.cc

    r95487027 ra43c561  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  7 13:17:56 2018
    13 // Update Count     : 192
     12// Last Modified On : Fri Jun  1 16:54:18 2018
     13// Update Count     : 155
    1414//
    1515
     
    1717#include "TypedefTable.h"
    1818#include <cassert>                                                                              // for assert
    19 #include <iostream>
    2019
    2120#if 0
     21#include <iostream>
    2222#define debugPrint( code ) code
    2323#else
     
    2727using namespace std;                                                                    // string, iostream
    2828
    29 debugPrint(
    30 static const char *kindName( int kind ) {
    31         switch ( kind ) {
    32           case IDENTIFIER: return "identifier";
    33           case TYPEDEFname: return "typedef";
    34           case TYPEGENname: return "typegen";
    35           default:
    36                 cerr << "Error: cfa-cpp internal error, invalid kind of identifier" << endl;
    37                 abort();
    38         } // switch
    39 } // kindName
    40 )
    41 
    4229TypedefTable::~TypedefTable() {
    4330        if ( ! SemanticErrorThrow && kindTable.currentScope() != 0 ) {
    44                 cerr << "Error: cfa-cpp internal error, scope failure " << kindTable.currentScope() << endl;
    45                 abort();
     31                std::cerr << "scope failure " << kindTable.currentScope() << endl;
    4632        } // if
    4733} // TypedefTable::~TypedefTable
     
    5844} // TypedefTable::isKind
    5945
     46void TypedefTable::changeKind( const string & identifier, int kind ) {
     47        KindTable::iterator posn = kindTable.find( identifier );
     48        if ( posn != kindTable.end() ) posn->second = kind;     // exists => update
     49} // TypedefTable::changeKind
     50
    6051// SKULLDUGGERY: Generate a typedef for the aggregate name so the aggregate does not have to be qualified by
    6152// "struct". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed if the
    6253// name is explicitly used.
    63 void TypedefTable::makeTypedef( const string & name, int kind ) {
    64 //    Check for existence is necessary to handle:
    65 //        struct Fred {};
    66 //        void Fred();
    67 //        void fred() {
    68 //           struct Fred act; // do not add as type in this scope
    69 //           Fred();
    70 //        }
     54void TypedefTable::makeTypedef( const string & name ) {
    7155        if ( ! typedefTable.exists( name ) ) {
    72                 typedefTable.addToEnclosingScope( name, kind, "MTD" );
     56                typedefTable.addToEnclosingScope( name, TYPEDEFname, "MTD" );
    7357        } // if
    7458} // TypedefTable::makeTypedef
    7559
    76 void TypedefTable::addToScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) {
     60void TypedefTable::addToScope( const std::string & identifier, int kind, const char * locn __attribute__((unused)) ) {
    7761        auto scope = kindTable.currentScope();
    78         debugPrint( cerr << "Adding current at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
     62        debugPrint( cerr << "Adding at " << locn << " " << identifier << " as kind " << kind << " scope " << scope << endl );
    7963        auto ret = kindTable.insertAt( scope, identifier, kind );
    8064        if ( ! ret.second ) ret.first->second = kind;           // exists => update
    8165} // TypedefTable::addToScope
    8266
    83 void TypedefTable::addToEnclosingScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) {
     67void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind, const char * locn __attribute__((unused)) ) {
    8468        assert( kindTable.currentScope() >= 1 );
    8569        auto scope = kindTable.currentScope() - 1;
    86         debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
     70        debugPrint( cerr << "Adding+1 at " << locn << " " << identifier << " as kind " << kind << " scope " << scope << endl );
    8771        auto ret = kindTable.insertAt( scope, identifier, kind );
    8872        if ( ! ret.second ) ret.first->second = kind;           // exists => update
     
    10993                        debugPrint( cerr << endl << "[" << scope << "]" );
    11094                } // while
    111                 debugPrint( cerr << " " << (*i).first << ":" << kindName( (*i).second ) );
     95                debugPrint( cerr << " " << (*i).first << ":" << (*i).second );
    11296        } // for
    11397        while ( scope > 0 ) {
  • src/Parser/TypedefTable.h

    r95487027 ra43c561  
    1010// Created On       : Sat May 16 15:24:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  7 12:10:17 2018
    13 // Update Count     : 85
     12// Last Modified On : Thu May 31 23:23:47 2018
     13// Update Count     : 83
    1414//
    1515
     
    3030        bool exists( const std::string & identifier );
    3131        int isKind( const std::string & identifier ) const;
    32         void makeTypedef( const std::string & name, int kind = TYPEDEFname );
     32        void changeKind( const std::string & identifier, int kind );
     33        void makeTypedef( const std::string & name );
    3334        void addToScope( const std::string & identifier, int kind, const char * );
    3435        void addToEnclosingScope( const std::string & identifier, int kind, const char * );
  • src/Parser/lex.ll

    r95487027 ra43c561  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Thu Jun  7 08:27:40 2018
    13  * Update Count     : 679
     12 * Last Modified On : Wed Jun  6 17:31:09 2018
     13 * Update Count     : 677
    1414 */
    1515
     
    452452
    453453%%
    454 
    455454// ----end of lexer----
    456455
    457456void yyerror( const char * errmsg ) {
    458         SemanticErrorThrow = true;
    459457        cout << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1
    460458                 << ": " << ErrorHelpers::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;
  • src/Parser/parser.yy

    r95487027 ra43c561  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun  7 10:07:12 2018
    13 // Update Count     : 3527
     12// Last Modified On : Wed Jun  6 14:53:38 2018
     13// Update Count     : 3522
    1414//
    1515
     
    18261826        | aggregate_key attribute_list_opt no_attr_identifier
    18271827                {
    1828                         typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname ); // create typedef
    1829                         //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update
     1828                        typedefTable.makeTypedef( *$3 );                        // create typedef
     1829                        if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update
    18301830                        forall = false;                                                         // reset
    18311831                }
     
    18341834        | aggregate_key attribute_list_opt type_name
    18351835                {
    1836                         typedefTable.makeTypedef( *$3->type->symbolic.name, forall ? TYPEGENname : TYPEDEFname ); // create typedef
    1837                         //if ( forall ) typedefTable.changeKind( *$3->type->symbolic.name, TYPEGENname ); // possibly update
     1836                        typedefTable.makeTypedef( *$3->type->symbolic.name ); // create typedef
     1837                        if ( forall ) typedefTable.changeKind( *$3->type->symbolic.name, TYPEGENname ); // possibly update
    18381838                        forall = false;                                                         // reset
    18391839                }
     
    18481848        aggregate_key attribute_list_opt no_attr_identifier
    18491849                {
    1850                         typedefTable.makeTypedef( *$3, forall ? TYPEGENname : TYPEDEFname );
    1851                         //if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update
     1850                        typedefTable.makeTypedef( *$3 );
     1851                        if ( forall ) typedefTable.changeKind( *$3, TYPEGENname ); // possibly update
    18521852                        forall = false;                                                         // reset
    18531853                        $$ = DeclarationNode::newAggregate( $1, $3, nullptr, nullptr, false )->addQualifiers( $2 );
     
    32643264
    32653265%%
    3266 
    32673266// ----end of grammar----
    32683267
Note: See TracChangeset for help on using the changeset viewer.