CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
cccc_tok.h
Go to the documentation of this file.
1 /*
2  CCCC - C and C++ Code Counter
3  Copyright (C) 1994-2005 Tim Littlefair (tim_littlefair@hotmail.com)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 /*
20  * cccc_tok.h
21  * definition of the token class interface for the cccc project
22  *
23  */
24 
25 #ifndef __CCCC_TOK_H
26 #define __CCCC_TOK_H
27 
28 #include "cccc.h"
29 
30 // before we go into the token header file, the compiler must have seen
31 // a definition for enum ANTLRTokenType
32 // there are three conflicting 'real' definitions, one in use by each parser
33 // if we have seen one of these, we do not need to worry, otherwise we
34 // must create a dummy one
35 // the three definitions are in the files Ctokens.h Jtokens.h and Atokens.h
36 #if !defined(Ctokens_h) && !defined(Jtokens_h) && !defined(Atokens_h)
38 #endif
39 
40 #include "AToken.h"
41 #include "cccc.h"
42 
43 
44 /*
45 ** the class definition for ANTLRToken
46 ** Note that the name ANTLRToken is required to be either a class or a typedef
47 ** by the PCCTS support code
48 */
49 class ANTLRToken : public ANTLRCommonToken {
50 
51  // Lexical counting is done by attaching running counts of each of the
52  // interesting features to every token produced by the lexer
53  // the parser calculates the counts for a particular region by taking
54  // taking the differences of the counts for the first and last tokens
55  // in the region's extent.
56 
57  // nesting levels are used to control resynchronisation
58  static int RunningNesting;
59 
60  static int numAllocated;
62  friend ostream& operator << (ostream&,ANTLRToken&);
63  friend class DLGLexer;
64  public:
65  static int bCodeLine;
66 
67  ANTLRToken(ANTLRTokenType t, ANTLRChar *s);
68  ANTLRToken(ANTLRToken& copyTok);
69  ANTLRToken();
70  ANTLRToken& operator=(ANTLRToken& copyTok);
71 
72  virtual ~ANTLRToken();
73 
74  virtual ANTLRAbstractToken *makeToken(ANTLRTokenType tt,
75  ANTLRChar *txt,
76  int line);
77 
78  static void IncrementNesting() { RunningNesting++; }
79  static void DecrementNesting() { RunningNesting--; }
80 
81  int getNestingLevel() { return CurrentNesting; }
82  void CountToken();
83  const char *getTokenTypeName();
84 };
85 
86 #define MY_TOK(t) ((ANTLRToken*)(t))
87 ostream& operator << (ostream&, ANTLRToken&);
88 
90 
91 
92 #endif
93 
94 
void CountToken()
Definition: cccc_tok.cc:153
ANTLRToken currentLexerToken
Definition: cccc_tok.cc:34
ANTLRToken & operator=(ANTLRToken &copyTok)
Definition: cccc_tok.cc:137
virtual ANTLRAbstractToken * makeToken(ANTLRTokenType tt, ANTLRChar *txt, int line)
Definition: cccc_tok.cc:103
static int numAllocated
Definition: cccc_tok.h:60
static void DecrementNesting()
Definition: cccc_tok.h:79
friend ostream & operator<<(ostream &, ANTLRToken &)
Definition: cccc_tok.cc:166
const char * getTokenTypeName()
Definition: cccc_tok.cc:161
static int bCodeLine
Definition: cccc_tok.h:65
ostream & operator<<(ostream &, ANTLRToken &)
Definition: cccc_tok.cc:166
int CurrentNesting
Definition: cccc_tok.h:61
static int RunningNesting
Definition: cccc_tok.h:58
static void IncrementNesting()
Definition: cccc_tok.h:78
ANTLRToken()
Definition: cccc_tok.cc:69
Definition: cccc_tok.h:37
friend class DLGLexer
Definition: cccc_tok.h:63
virtual ~ANTLRToken()
Definition: cccc_tok.cc:128
int getNestingLevel()
Definition: cccc_tok.h:81
ANTLRTokenType
Definition: cccc_tok.h:37