2008-10-26 08:55:15 +01:00
|
|
|
/*
|
|
|
|
* c++check - c/c++ syntax checking
|
|
|
|
* Copyright (C) 2007 Daniel Marjamäki
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-05-24 07:40:45 +02:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#ifndef tokenizeH
|
|
|
|
#define tokenizeH
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
extern std::vector<std::string> Files;
|
|
|
|
|
2008-11-06 19:31:39 +01:00
|
|
|
class TOKEN
|
2007-05-24 07:40:45 +02:00
|
|
|
{
|
2008-11-06 19:31:39 +01:00
|
|
|
private:
|
|
|
|
char * _str;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TOKEN()
|
|
|
|
{ FileIndex = 0; _str = 0; linenr = 0; next = 0; }
|
|
|
|
|
|
|
|
~TOKEN()
|
|
|
|
{ free(_str); }
|
|
|
|
|
|
|
|
void setstr( const char s[] )
|
|
|
|
{ free(_str); _str = strdup(s); str = _str ? _str : ""; }
|
|
|
|
|
|
|
|
const char *str;
|
|
|
|
|
2007-05-24 07:40:45 +02:00
|
|
|
unsigned int FileIndex;
|
|
|
|
unsigned int linenr;
|
2008-11-06 19:31:39 +01:00
|
|
|
TOKEN *next;
|
2007-05-24 07:40:45 +02:00
|
|
|
};
|
2008-11-06 19:31:39 +01:00
|
|
|
extern TOKEN *tokens, *tokens_back;
|
2007-05-24 07:40:45 +02:00
|
|
|
|
|
|
|
|
2008-10-30 20:42:34 +01:00
|
|
|
void Tokenize(std::istream &code, const char FileName[]);
|
2007-05-24 07:40:45 +02:00
|
|
|
|
2008-02-16 16:46:32 +01:00
|
|
|
void TokenizeCode(std::istream &code, const unsigned int FileIndex=0);
|
|
|
|
|
2007-05-30 22:08:05 +02:00
|
|
|
// Return size.
|
|
|
|
int SizeOfType(const char type[]);
|
|
|
|
|
2007-05-29 08:24:36 +02:00
|
|
|
// Simplify tokenlist
|
|
|
|
// -----------------------------
|
|
|
|
void SimplifyTokenList();
|
|
|
|
|
2007-05-24 15:07:30 +02:00
|
|
|
|
2007-05-29 19:11:53 +02:00
|
|
|
// Deallocate lists..
|
|
|
|
void DeallocateTokens();
|
|
|
|
|
|
|
|
|
2007-05-24 15:07:30 +02:00
|
|
|
// Helper functions for handling the tokens list..
|
2008-03-22 12:46:06 +01:00
|
|
|
const TOKEN *findtoken(const TOKEN *tok1, const char *tokenstr[]);
|
|
|
|
const TOKEN *gettok(const TOKEN *tok, int index);
|
|
|
|
const char *getstr(const TOKEN *tok, int index);
|
2007-05-24 15:07:30 +02:00
|
|
|
|
2008-04-11 20:37:15 +02:00
|
|
|
|
2007-05-24 07:40:45 +02:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#endif
|
|
|
|
|