mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 10:49:57 +00:00
78 lines
2.2 KiB
C++
78 lines
2.2 KiB
C++
|
#ifndef CSV_WORLD_SCRIPTHIGHLIGHTER_H
|
||
|
#define CSV_WORLD_SCRIPTHIGHLIGHTER_H
|
||
|
|
||
|
#include <map>
|
||
|
|
||
|
#include <QSyntaxHighlighter>
|
||
|
|
||
|
#include <components/compiler/nullerrorhandler.hpp>
|
||
|
#include <components/compiler/parser.hpp>
|
||
|
|
||
|
#include "../../model/world/scriptcontext.hpp"
|
||
|
|
||
|
namespace CSVWorld
|
||
|
{
|
||
|
class ScriptHighlighter : public QSyntaxHighlighter, private Compiler::Parser
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
enum Type
|
||
|
{
|
||
|
Type_Int,
|
||
|
Type_Float,
|
||
|
Type_Name,
|
||
|
Type_Keyword,
|
||
|
Type_Special
|
||
|
};
|
||
|
|
||
|
private:
|
||
|
|
||
|
Compiler::NullErrorHandler mErrorHandler;
|
||
|
CSMWorld::ScriptContext mContext;
|
||
|
std::map<Type, QTextCharFormat> mScheme;
|
||
|
|
||
|
private:
|
||
|
|
||
|
virtual bool parseInt (int value, const Compiler::TokenLoc& loc,
|
||
|
Compiler::Scanner& scanner);
|
||
|
///< Handle an int token.
|
||
|
/// \return fetch another token?
|
||
|
|
||
|
virtual bool parseFloat (float value, const Compiler::TokenLoc& loc,
|
||
|
Compiler::Scanner& scanner);
|
||
|
///< Handle a float token.
|
||
|
/// \return fetch another token?
|
||
|
|
||
|
virtual bool parseName (const std::string& name,
|
||
|
const Compiler::TokenLoc& loc, Compiler::Scanner& scanner);
|
||
|
///< Handle a name token.
|
||
|
/// \return fetch another token?
|
||
|
|
||
|
virtual bool parseKeyword (int keyword, const Compiler::TokenLoc& loc,
|
||
|
Compiler::Scanner& scanner);
|
||
|
///< Handle a keyword token.
|
||
|
/// \return fetch another token?
|
||
|
|
||
|
virtual bool parseSpecial (int code, const Compiler::TokenLoc& loc,
|
||
|
Compiler::Scanner& scanner);
|
||
|
///< Handle a special character token.
|
||
|
/// \return fetch another token?
|
||
|
|
||
|
///< Handle a special character token.
|
||
|
/// \return fetch another token?
|
||
|
|
||
|
virtual void parseEOF (Compiler::Scanner& scanner);
|
||
|
///< Handle EOF token.
|
||
|
|
||
|
void highlight (const Compiler::TokenLoc& loc, Type type);
|
||
|
|
||
|
public:
|
||
|
|
||
|
ScriptHighlighter (QTextDocument *parent);
|
||
|
|
||
|
virtual void highlightBlock (const QString& text);
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif
|