Modules | Files | Inheritance Tree | Inheritance Graph | Name Index | Config
File: Synopsis/Parser/C++/syn/link_map.hh
    1| // Synopsis C++ Parser: link_map.hh header file
    2| // The LinkMap class which maps preprocessed file positions to input file
    3| // positions
    4| 
    5| // $Id: link_map.hh,v 1.5 2003/01/27 06:53:37 chalky Exp $
    6| //
    7| // This file is a part of Synopsis.
    8| // Copyright (C) 2002 Stephen Davies
    9| //
   10| // Synopsis is free software; you can redistribute it and/or modify it
   11| // under the terms of the GNU General Public License as published by
   12| // the Free Software Foundation; either version 2 of the License, or
   13| // (at your option) any later version.
   14| //
   15| // This program is distributed in the hope that it will be useful,
   16| // but WITHOUT ANY WARRANTY; without even the implied warranty of
   17| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18| // General Public License for more details.
   19| //
   20| // You should have received a copy of the GNU General Public License
   21| // along with this program; if not, write to the Free Software
   22| // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   23| // 02111-1307, USA.
   24| 
   25| 
   26| #ifndef H_SYNOPSIS_CPP_LINKMAP
   27| #define H_SYNOPSIS_CPP_LINKMAP
   28| 
   29| #include <vector>
   30| #include "ast.hh"
   31| 
   32| //. Declared in link_map.cc just because all the ucpp->synopsis hooks are
   33| //. there for now.
   34| extern std::vector<AST::Macro*>* syn_macro_defines;
   35| 
   36| //. LinkMap is a map from preprocessed file positions to input file positions
   37| class LinkMap
   38| {
   39| public:
   40|     //. Constructor
   41|     LinkMap();
   42| 
   43|     //. Returns a reference to a singleton instance of link_map
   44|     static LinkMapinstance();
   45| 
   46|     //. Adds a map at the given line. out_{start,end} define the start and
   47|     //. past-the-end markers for the macro in the output file. diff defines
   48|     //. the signed difference to add to the pos.
   49|     //. @see map(int, int)
   50|     void add(const char* name, int line, int out_start, int out_end, int diff);
   51| 
   52|     //. Applies added maps to the given column number. The differentials of
   53|     //. the various macros are applied in turn, and the final column position is
   54|     //. returned. Returns -1 if col is inside a macro
   55|     int map(int line, int col);
   56| 
   57|     //. Clears the map. Should be called at the very start of processing,
   58|     //. since the map is stored statically and hence potentially across parser
   59|     //. invocations.
   60|     void clear();
   61| 
   62| private:
   63|     //. Compiler firewall
   64|     struct Private;
   65|     Private *m;
   66| };
   67| 
   68| #endif