2008-11-22 23:49:14 +01:00
|
|
|
/*
|
|
|
|
* c++check - c/c++ syntax checking
|
|
|
|
* Copyright (C) 2007-2008 Daniel Marjamäki and Reijo Tomperi
|
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TOKEN_H
|
|
|
|
#define TOKEN_H
|
|
|
|
|
|
|
|
class TOKEN
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TOKEN();
|
|
|
|
~TOKEN();
|
|
|
|
void setstr( const char s[] );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Combine two tokens that belong to each other.
|
|
|
|
* Ex: "<" and "=" may become "<="
|
|
|
|
*/
|
|
|
|
void combineWithNext(const char str1[], const char str2[]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unlink and delete next token.
|
|
|
|
*/
|
|
|
|
void deleteNext();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns token in given index, related to this token.
|
|
|
|
* For example index 1 would return next token, and 2
|
|
|
|
* would return next from that one.
|
|
|
|
*/
|
2008-11-23 11:09:16 +01:00
|
|
|
const TOKEN *tokAt(int index) const;
|
|
|
|
|
|
|
|
const char *strAt(int index) const;
|
2008-11-22 23:49:14 +01:00
|
|
|
|
|
|
|
static bool Match(const TOKEN *tok, const char pattern[], const char *varname1[]=0, const char *varname2[]=0);
|
2008-11-23 13:21:40 +01:00
|
|
|
bool isName() const;
|
|
|
|
bool isNumber() const;
|
2008-11-22 23:49:14 +01:00
|
|
|
static bool IsStandardType(const char str[]);
|
|
|
|
static const TOKEN *findmatch(const TOKEN *tok, const char pattern[], const char *varname1[]=0, const char *varname2[]=0);
|
|
|
|
static const TOKEN *findtoken(const TOKEN *tok1, const char *tokenstr[]);
|
|
|
|
const char *str;
|
|
|
|
unsigned int FileIndex;
|
|
|
|
unsigned int linenr;
|
|
|
|
TOKEN *next;
|
|
|
|
|
|
|
|
private:
|
|
|
|
char * _str;
|
2008-11-23 13:21:40 +01:00
|
|
|
bool _isName;
|
|
|
|
bool _isNumber;
|
2008-11-22 23:49:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TOKEN_H
|