polserver/pol-core/bscript/token.h
turleypol 6cc0d1698b
Clang Tidy replace typedefs with more readable using (#854)
* trigger tidy

* Automated clang-tidy change: modernize-use-using

* compile test

* unnamed struct fix?

* more unnamed structs

---------

Co-authored-by: Clang Tidy <clang-tidy@users.noreply.github.com>
2026-01-16 18:45:47 +01:00

82 lines
1.2 KiB
C++

/** @file
*
* @par History
*/
#ifndef __TOKEN_H
#define __TOKEN_H
#ifndef __TOKENS_H
#include "tokens.h"
#endif
#ifndef __MODULES_H
#include "modules.h"
#endif
#include <iosfwd>
#include <set>
#include <fmt/ostream.h>
namespace Pol
{
namespace Bscript
{
struct DebugToken
{
unsigned sourceFile;
unsigned offset;
unsigned strOffset;
};
class Token
{
public:
BTokenId id;
BTokenType type;
double dval;
union
{
int precedence;
int sourceFile;
};
int dbg_filenum;
int dbg_linenum;
union
{
int lval;
const unsigned char* dataptr;
};
bool deprecated;
unsigned char module;
static unsigned int instances();
static void show_instances();
protected:
std::string token;
public:
const char* tokval() const { return token.c_str(); }
Token();
void nulStr();
void setStr( std::string str );
void printOn( std::ostream& outputStream ) const;
};
std::ostream& operator<<( std::ostream&, const Token& );
} // namespace Bscript
namespace Clib
{
template <>
std::string tostring<Bscript::Token>( const Bscript::Token& v );
}
} // namespace Pol
template <>
struct fmt::formatter<Pol::Bscript::Token> : fmt::ostream_formatter
{
};
#endif