2010-06-28 09:38:04 +00:00
|
|
|
#ifndef COMPILER_SCRIPTPARSER_H_INCLUDED
|
|
|
|
#define COMPILER_SCRIPTPARSER_H_INCLUDED
|
|
|
|
|
2010-06-30 17:58:25 +00:00
|
|
|
#include "controlparser.hpp"
|
2010-06-28 10:12:47 +00:00
|
|
|
#include "lineparser.hpp"
|
2010-06-28 14:48:19 +00:00
|
|
|
#include "output.hpp"
|
2010-06-28 09:38:04 +00:00
|
|
|
#include "parser.hpp"
|
|
|
|
|
|
|
|
namespace Compiler
|
|
|
|
{
|
2010-06-28 11:28:50 +00:00
|
|
|
class Locals;
|
|
|
|
|
2010-06-28 09:38:04 +00:00
|
|
|
// Script parser, to be used in dialogue scripts and as part of FileParser
|
2014-02-14 11:23:00 +00:00
|
|
|
|
2010-06-28 09:38:04 +00:00
|
|
|
class ScriptParser : public Parser
|
|
|
|
{
|
2010-06-28 14:48:19 +00:00
|
|
|
Output mOutput;
|
2010-06-28 10:12:47 +00:00
|
|
|
LineParser mLineParser;
|
2010-06-30 17:58:25 +00:00
|
|
|
ControlParser mControlParser;
|
2010-06-28 09:38:04 +00:00
|
|
|
bool mEnd;
|
2014-02-14 11:23:00 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
2010-06-28 09:38:04 +00:00
|
|
|
/// \param end of script is marked by end keyword.
|
2014-02-14 11:23:00 +00:00
|
|
|
ScriptParser(ErrorHandler& errorHandler, const Context& context, Locals& locals, bool end = false);
|
|
|
|
|
2023-01-10 03:10:18 +00:00
|
|
|
Interpreter::Program getProgram() const;
|
2014-02-14 11:23:00 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool parseName(const std::string& name, const TokenLoc& loc, Scanner& scanner) override;
|
2010-06-28 09:38:04 +00:00
|
|
|
///< Handle a name token.
|
|
|
|
/// \return fetch another token?
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool parseKeyword(int keyword, const TokenLoc& loc, Scanner& scanner) override;
|
2010-06-28 09:38:04 +00:00
|
|
|
///< Handle a keyword token.
|
|
|
|
/// \return fetch another token?
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool parseSpecial(int code, const TokenLoc& loc, Scanner& scanner) override;
|
2010-06-28 09:38:04 +00:00
|
|
|
///< Handle a special character token.
|
|
|
|
/// \return fetch another token?
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void parseEOF(Scanner& scanner) override;
|
2014-02-14 11:23:00 +00:00
|
|
|
///< Handle EOF token.
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void reset() override;
|
2010-06-28 09:38:04 +00:00
|
|
|
///< Reset parser to clean state.
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|