2008-12-18 22:28:57 +01:00
|
|
|
/*
|
2008-12-19 22:15:06 +01:00
|
|
|
* cppcheck - c/c++ syntax checking
|
2009-01-07 16:43:20 +01:00
|
|
|
* Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam
|
2008-12-18 22:28:57 +01:00
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "token.h"
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
|
2009-01-07 16:43:20 +01:00
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#include <ctype.h> // isalpha, isdigit
|
|
|
|
#endif
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
Token::Token() :
|
2009-01-05 16:49:57 +01:00
|
|
|
_str(""),
|
|
|
|
_cstr(0),
|
|
|
|
_isName(false),
|
|
|
|
_isNumber(false),
|
|
|
|
_isBoolean(false),
|
|
|
|
_varId(0),
|
|
|
|
_next(0),
|
|
|
|
_previous(0),
|
|
|
|
_fileIndex(0),
|
|
|
|
_linenr(0)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
Token::~Token()
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
std::free(_cstr);
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::str(const char s[])
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
_str = s;
|
|
|
|
std::free(_cstr);
|
|
|
|
_cstr = strdup(s);
|
2009-01-07 16:43:20 +01:00
|
|
|
_isName = bool(_str[0] == '_' || isalpha(_str[0]));
|
|
|
|
_isNumber = bool(isdigit(_str[0]) != 0);
|
2009-01-05 16:49:57 +01:00
|
|
|
if (_str == "true" || _str == "false")
|
2008-12-21 14:58:56 +01:00
|
|
|
_isBoolean = true;
|
|
|
|
else
|
|
|
|
_isBoolean = false;
|
|
|
|
|
2008-12-18 22:28:57 +01:00
|
|
|
_varId = 0;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
void Token::deleteNext()
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-03 21:29:20 +01:00
|
|
|
Token *n = _next;
|
2008-12-18 22:28:57 +01:00
|
|
|
_next = n->next();
|
2008-12-17 20:20:11 +01:00
|
|
|
delete n;
|
|
|
|
if (_next)
|
2008-12-18 22:28:57 +01:00
|
|
|
_next->previous(this);
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
const Token *Token::tokAt(int index) const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-03 21:29:20 +01:00
|
|
|
const Token *tok = this;
|
2009-01-05 16:49:57 +01:00
|
|
|
while (index > 0 && tok)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
tok = tok->next();
|
2009-01-01 23:22:28 +01:00
|
|
|
--index;
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
return tok;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
const char *Token::strAt(int index) const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-03 21:29:20 +01:00
|
|
|
const Token *tok = this->tokAt(index);
|
2008-12-18 22:28:57 +01:00
|
|
|
return tok ? tok->_cstr : "";
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
int Token::multiCompare(const char *needle, const char *haystack)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
bool emptyStringFound = false;
|
|
|
|
bool findNextOr = false;
|
|
|
|
const char *haystackPointer = haystack;
|
2009-01-05 16:49:57 +01:00
|
|
|
for (; *needle; ++needle)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
if (*needle == '|')
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
// If needle and haystack are both at the end, we have a match.
|
2009-01-05 16:49:57 +01:00
|
|
|
if (*haystackPointer == 0)
|
2008-12-18 22:28:57 +01:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
haystackPointer = haystack;
|
2009-01-05 16:49:57 +01:00
|
|
|
if (findNextOr)
|
2008-12-18 22:28:57 +01:00
|
|
|
findNextOr = false;
|
|
|
|
else
|
|
|
|
emptyStringFound = true;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
if (findNextOr)
|
2008-12-18 22:28:57 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// If haystack and needle don't share the same character, reset
|
|
|
|
// haystackpointer and find next '|' character.
|
2009-01-05 16:49:57 +01:00
|
|
|
if (*haystackPointer != *needle)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
haystackPointer = haystack;
|
|
|
|
findNextOr = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// All characters in haystack and needle have matched this far
|
2009-01-01 23:22:28 +01:00
|
|
|
++haystackPointer;
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// If both needle and haystack are at the end, then we have a match.
|
2009-01-05 16:49:57 +01:00
|
|
|
if (*haystackPointer == 0)
|
2008-12-18 22:28:57 +01:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
// If empty string was found or if last character in needle was '|'
|
2009-01-05 16:49:57 +01:00
|
|
|
if (emptyStringFound || findNextOr == false)
|
2008-12-18 22:28:57 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
bool Token::simpleMatch(const Token *tok, const char pattern[])
|
2008-12-22 00:28:09 +01:00
|
|
|
{
|
2008-12-23 22:45:47 +01:00
|
|
|
const char *current, *next;
|
|
|
|
|
|
|
|
current = pattern;
|
2008-12-25 19:24:57 +01:00
|
|
|
next = strchr(pattern, ' ');
|
2009-01-05 16:49:57 +01:00
|
|
|
if (!next)
|
2008-12-23 22:45:47 +01:00
|
|
|
next = pattern + strlen(pattern);
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
while (*current)
|
2008-12-22 00:28:09 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
size_t length = static_cast<size_t>(next - current);
|
2008-12-23 22:45:47 +01:00
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
if (!tok || length != tok->_str.length() || strncmp(current, tok->_cstr, length))
|
2008-12-22 00:28:09 +01:00
|
|
|
return false;
|
2008-12-23 22:45:47 +01:00
|
|
|
|
|
|
|
current = next;
|
2009-01-05 16:49:57 +01:00
|
|
|
if (*next)
|
2008-12-25 19:24:57 +01:00
|
|
|
{
|
|
|
|
next = strchr(++current, ' ');
|
2009-01-05 16:49:57 +01:00
|
|
|
if (!next)
|
2008-12-25 19:24:57 +01:00
|
|
|
next = current + strlen(current);
|
2008-12-23 22:45:47 +01:00
|
|
|
}
|
|
|
|
tok = tok->next();
|
2008-12-22 00:28:09 +01:00
|
|
|
}
|
2008-12-23 22:45:47 +01:00
|
|
|
|
2008-12-22 00:28:09 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-06 00:06:51 +01:00
|
|
|
bool Token::Match(const Token *tok, const char pattern[], unsigned int varid)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
const char *p = pattern;
|
2009-01-05 16:49:57 +01:00
|
|
|
while (*p)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
// Skip spaces in pattern..
|
2009-01-05 16:49:57 +01:00
|
|
|
while (*p == ' ')
|
2009-01-01 23:22:28 +01:00
|
|
|
++p;
|
2008-12-18 22:28:57 +01:00
|
|
|
|
|
|
|
// Extract token from pattern..
|
|
|
|
// TODO: Refactor this so there can't be buffer overflows
|
|
|
|
char str[500];
|
|
|
|
char *s = str;
|
2009-01-05 16:49:57 +01:00
|
|
|
while (*p && *p != ' ')
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
*s = *p;
|
2009-01-01 23:22:28 +01:00
|
|
|
++s;
|
|
|
|
++p;
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
*s = 0;
|
|
|
|
|
|
|
|
// No token => Success!
|
|
|
|
if (str[0] == 0)
|
|
|
|
return true;
|
|
|
|
|
2009-01-10 01:33:48 +01:00
|
|
|
if (!tok)
|
|
|
|
{
|
|
|
|
// If we have no tokens, pattern "!!else" should return true
|
|
|
|
if (str[1] == '!' && str[0] == '!' && strlen(str) > 2)
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
// Compare the first character of the string for optimization reasons
|
|
|
|
// before doing more detailed checks.
|
2008-12-23 21:17:05 +01:00
|
|
|
bool patternIdentified = false;
|
2009-01-05 16:49:57 +01:00
|
|
|
if (str[0] == '%')
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2008-12-23 21:17:05 +01:00
|
|
|
// Any symbolname..
|
2009-01-05 16:49:57 +01:00
|
|
|
if (strcmp(str, "%var%") == 0 || strcmp(str, "%type%") == 0)
|
2008-12-23 21:17:05 +01:00
|
|
|
{
|
|
|
|
if (!tok->isName())
|
|
|
|
return false;
|
2008-12-18 22:28:57 +01:00
|
|
|
|
2008-12-23 21:17:05 +01:00
|
|
|
patternIdentified = true;
|
|
|
|
}
|
2008-12-18 22:28:57 +01:00
|
|
|
|
2008-12-23 21:17:05 +01:00
|
|
|
// Accept any token
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (strcmp(str, "%any%") == 0)
|
2008-12-23 21:17:05 +01:00
|
|
|
{
|
|
|
|
patternIdentified = true;
|
|
|
|
}
|
2008-12-18 22:28:57 +01:00
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (strcmp(str, "%varid%") == 0)
|
2008-12-23 21:17:05 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
if (varid == 0)
|
2009-01-04 21:33:12 +01:00
|
|
|
{
|
|
|
|
std::cout << "\n###### If you see this, there is a bug ###### Token::Match() - varid was 0" << std::endl;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
if (tok->varId() != varid)
|
2008-12-18 22:28:57 +01:00
|
|
|
return false;
|
|
|
|
|
2008-12-23 21:17:05 +01:00
|
|
|
patternIdentified = true;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (strcmp(str, "%num%") == 0)
|
2008-12-23 21:17:05 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
if (!tok->isNumber())
|
2008-12-18 22:28:57 +01:00
|
|
|
return false;
|
|
|
|
|
2008-12-23 21:17:05 +01:00
|
|
|
patternIdentified = true;
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (strcmp(str, "%bool%") == 0)
|
2008-12-23 21:17:05 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
if (!tok->isBoolean())
|
2008-12-23 21:17:05 +01:00
|
|
|
return false;
|
2008-12-18 22:28:57 +01:00
|
|
|
|
2008-12-23 21:17:05 +01:00
|
|
|
patternIdentified = true;
|
|
|
|
}
|
2008-12-18 22:28:57 +01:00
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (strcmp(str, "%str%") == 0)
|
2008-12-23 21:17:05 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
if (tok->_str[0] != '\"')
|
2008-12-23 21:17:05 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
patternIdentified = true;
|
|
|
|
}
|
2008-12-21 14:58:56 +01:00
|
|
|
}
|
2008-12-18 22:28:57 +01:00
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
if (patternIdentified)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2008-12-23 21:17:05 +01:00
|
|
|
// Pattern was identified already above.
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// [.. => search for a one-character token..
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (str[0] == '[' && strchr(str, ']') && tok->_str[1] == 0)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
*strrchr(str, ']') = 0;
|
2009-01-05 16:49:57 +01:00
|
|
|
if (strchr(str + 1, tok->_str[0]) == 0)
|
2008-12-18 22:28:57 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse multi options, such as void|int|char (accept token which is one of these 3)
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (strchr(str, '|') && strlen(str) > 2)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
int res = multiCompare(str, tok->_cstr);
|
|
|
|
if (res == 0)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
// Empty alternative matches, use the same token on next round
|
|
|
|
continue;
|
|
|
|
}
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (res == -1)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
// No match
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse "not" options. Token can be anything except the given one
|
2009-01-05 16:49:57 +01:00
|
|
|
else if (str[1] == '!' && str[0] == '!' && strlen(str) > 2)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
if (strcmp(tok->aaaa(), &(str[2])) == 0)
|
2008-12-18 22:28:57 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (str != tok->_str)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
tok = tok->next();
|
|
|
|
}
|
|
|
|
|
|
|
|
// The end of the pattern has been reached and nothing wrong has been found
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
bool Token::isName() const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
return _isName;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
bool Token::isNumber() const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
return _isNumber;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
bool Token::isBoolean() const
|
2008-12-21 14:58:56 +01:00
|
|
|
{
|
|
|
|
return _isBoolean;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
bool Token::isStandardType() const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
bool ret = false;
|
2009-01-05 16:49:57 +01:00
|
|
|
const char *type[] = {"bool", "char", "short", "int", "long", "float", "double", 0};
|
2008-12-18 22:28:57 +01:00
|
|
|
for (int i = 0; type[i]; i++)
|
|
|
|
ret |= (_str == type[i]);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
const Token *Token::findmatch(const Token *tok, const char pattern[], unsigned int varId)
|
2009-01-04 20:55:12 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
for (; tok; tok = tok->next())
|
2009-01-04 20:55:12 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
if (Token::Match(tok, pattern, varId))
|
2009-01-04 20:55:12 +01:00
|
|
|
return tok;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
unsigned int Token::varId() const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
return _varId;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::varId(unsigned int id)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
_varId = id;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
Token *Token::next() const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
return _next;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::next(Token *next)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
_next = next;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
Token *Token::previous() const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
return _previous;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::previous(Token *previous)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
_previous = previous;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::insertToken(const char str[])
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-03 21:29:20 +01:00
|
|
|
Token *newToken = new Token;
|
2009-01-05 16:49:57 +01:00
|
|
|
newToken->str(str);
|
2008-12-16 18:05:43 +01:00
|
|
|
newToken->_linenr = _linenr;
|
2008-12-18 22:28:57 +01:00
|
|
|
newToken->_fileIndex = _fileIndex;
|
2009-01-05 16:49:57 +01:00
|
|
|
if (this->next())
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
newToken->next(this->next());
|
|
|
|
newToken->next()->previous(newToken);
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
this->next(newToken);
|
|
|
|
newToken->previous(this);
|
2008-12-18 22:28:57 +01:00
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::eraseTokens(Token *begin, const Token *end)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
2009-01-05 16:49:57 +01:00
|
|
|
if (! begin)
|
2008-12-18 22:28:57 +01:00
|
|
|
return;
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
while (begin->next() && begin->next() != end)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
begin->deleteNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
unsigned int Token::fileIndex() const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
return _fileIndex;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::fileIndex(unsigned int fileIndex)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
_fileIndex = fileIndex;
|
|
|
|
}
|
|
|
|
|
2009-01-03 21:29:20 +01:00
|
|
|
unsigned int Token::linenr() const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
return _linenr;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::linenr(unsigned int linenr)
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
_linenr = linenr;
|
|
|
|
}
|
|
|
|
|
2009-01-05 16:49:57 +01:00
|
|
|
void Token::printOut(const char *title) const
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
std::cout << std::endl << "###";
|
2009-01-05 16:49:57 +01:00
|
|
|
if (title)
|
2008-12-18 22:28:57 +01:00
|
|
|
std::cout << " " << title << " ";
|
|
|
|
else
|
|
|
|
std::cout << "########";
|
|
|
|
|
|
|
|
std::cout << "###" << std::endl;
|
2009-01-05 16:49:57 +01:00
|
|
|
for (const Token *t = this; t; t = t->next())
|
2008-12-18 22:28:57 +01:00
|
|
|
{
|
|
|
|
std::cout << t->linenr() << ": " << t->str();
|
2009-01-05 16:49:57 +01:00
|
|
|
if (t->varId())
|
|
|
|
std::cout << " (" << t->varId() << ")";
|
2008-12-18 22:28:57 +01:00
|
|
|
|
|
|
|
std::cout << std::endl;
|
|
|
|
}
|
|
|
|
}
|