Changeset fc95df3 for src/Parser


Ignore:
Timestamp:
Jul 12, 2023, 7:26:16 AM (11 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
71a422a
Parents:
bdbb448
Message:

add additional debug printing

Location:
src/Parser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypedefTable.cc

    rbdbb448 rfc95df3  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb 15 08:27:24 2022
    13 // Update Count     : 275
     12// Last Modified On : Wed Jul 12 06:11:28 2023
     13// Update Count     : 276
    1414//
    1515
     
    1717#include "TypedefTable.h"
    1818
    19 #include <cassert>                                // for assert
    20 #include <string>                                 // for string
    21 #include <iostream>                               // for iostream
     19#include <cassert>                                                                              // for assert
     20#include <string>                                                                               // for string
     21#include <iostream>                                                                             // for iostream
    2222
    23 #include "ExpressionNode.h"                       // for LabelNode
    24 #include "ParserTypes.h"                          // for Token
    25 #include "StatementNode.h"                        // for CondCtl, ForCtrl
     23#include "ExpressionNode.h"                                                             // for LabelNode
     24#include "ParserTypes.h"                                                                // for Token
     25#include "StatementNode.h"                                                              // for CondCtl, ForCtrl
    2626// This (generated) header must come late as it is missing includes.
    27 #include "parser.hh"              // for IDENTIFIER, TYPEDEFname, TYPEGENname
     27#include "parser.hh"                                                                    // for IDENTIFIER, TYPEDEFname, TYPEGENname
    2828
    2929using namespace std;
     
    7272// "struct". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed if the
    7373// name is explicitly used.
    74 void TypedefTable::makeTypedef( const string & name, int kind ) {
     74void TypedefTable::makeTypedef( const string & name, int kind, const char * locn __attribute__((unused)) ) {
    7575//    Check for existence is necessary to handle:
    7676//        struct Fred {};
     
    8080//           Fred();
    8181//        }
     82        debugPrint( cerr << "Make typedef at " << locn << " \"" << name << "\" as " << kindName( kind ) << " scope " << kindTable.currentScope() << endl );
    8283        if ( ! typedefTable.exists( name ) ) {
    8384                typedefTable.addToEnclosingScope( name, kind, "MTD" );
     
    8586} // TypedefTable::makeTypedef
    8687
    87 void TypedefTable::makeTypedef( const string & name ) {
    88         return makeTypedef( name, TYPEDEFname );
     88void TypedefTable::makeTypedef( const string & name, const char * locn __attribute__((unused)) ) {
     89        debugPrint( cerr << "Make typedef at " << locn << " \"" << name << " scope " << kindTable.currentScope() << endl );
     90        return makeTypedef( name, TYPEDEFname, "makeTypede" );
    8991} // TypedefTable::makeTypedef
    9092
    9193void TypedefTable::addToScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) {
    9294        KindTable::size_type scope = kindTable.currentScope();
    93         debugPrint( cerr << "Adding current at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
     95        debugPrint( cerr << "Adding current at " << locn << " \"" << identifier << "\" as " << kindName( kind ) << " scope " << scope << endl );
    9496        kindTable.insertAt( scope, identifier, kind );
    9597} // TypedefTable::addToScope
     
    98100        KindTable::size_type scope = kindTable.currentScope() - 1 - kindTable.getNote( kindTable.currentScope() - 1 ).level;
    99101//      size_type scope = level - kindTable.getNote( kindTable.currentScope() - 1 ).level;
    100         debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << " level " << level << " note " << kindTable.getNote( kindTable.currentScope() - 1 ).level << endl );
     102        debugPrint( cerr << "Adding enclosing at " << locn << " \"" << identifier << "\" as " << kindName( kind ) << " scope " << scope << " level " << level << " note " << kindTable.getNote( kindTable.currentScope() - 1 ).level << endl );
    101103        pair< KindTable::iterator, bool > ret = kindTable.insertAt( scope, identifier, kind );
    102104        if ( ! ret.second ) ret.first->second = kind;           // exists => update
  • src/Parser/TypedefTable.h

    rbdbb448 rfc95df3  
    1010// Created On       : Sat May 16 15:24:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 15 08:06:37 2020
    13 // Update Count     : 117
     12// Last Modified On : Wed Jul 12 06:09:37 2023
     13// Update Count     : 118
    1414//
    1515
     
    2121
    2222class TypedefTable {
    23         struct Note { size_t level; bool forall; };
     23        struct Note {
     24                size_t level;
     25                bool forall;
     26        };
    2427        typedef ScopedMap< std::string, int, Note > KindTable;
    2528        KindTable kindTable;
     
    3134        bool existsCurr( const std::string & identifier ) const;
    3235        int isKind( const std::string & identifier ) const;
    33         void makeTypedef( const std::string & name, int kind );
    34         void makeTypedef( const std::string & name );
     36        void makeTypedef( const std::string & name, int kind, const char * );
     37        void makeTypedef( const std::string & name, const char * );
    3538        void addToScope( const std::string & identifier, int kind, const char * );
    3639        void addToEnclosingScope( const std::string & identifier, int kind, const char * );
Note: See TracChangeset for help on using the changeset viewer.