2010-06-28 09:38:04 +00:00
|
|
|
#ifndef COMPILER_SCRIPTPARSER_H_INCLUDED
|
|
|
|
#define COMPILER_SCRIPTPARSER_H_INCLUDED
|
|
|
|
|
2010-06-28 12:07:55 +00:00
|
|
|
|
2010-06-28 09:38:04 +00:00
|
|
|
#include "parser.hpp"
|
2010-06-28 10:12:47 +00:00
|
|
|
#include "lineparser.hpp"
|
2010-06-30 17:58:25 +00:00
|
|
|
#include "controlparser.hpp"
|
2010-06-28 14:48:19 +00:00
|
|
|
#include "output.hpp"
|
2010-06-28 09:38:04 +00:00
|
|
|
|
|
|
|
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;
|
2010-06-28 14:48:19 +00:00
|
|
|
|
2010-06-28 09:38:04 +00:00
|
|
|
public:
|
2014-02-14 11:23:00 +00:00
|
|
|
|
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,
|
2010-06-28 11:28:50 +00:00
|
|
|
bool end = false);
|
2014-02-14 11:23:00 +00:00
|
|
|
|
2010-06-28 12:07:55 +00:00
|
|
|
void getCode (std::vector<Interpreter::Type_Code>& code) const;
|
2014-06-15 13:58:01 +00:00
|
|
|
///< store generated code in \a code.
|
2014-02-14 11:23:00 +00:00
|
|
|
|
2010-06-28 09:38:04 +00:00
|
|
|
virtual bool parseName (const std::string& name, const TokenLoc& loc,
|
|
|
|
Scanner& scanner);
|
|
|
|
///< Handle a name token.
|
|
|
|
/// \return fetch another token?
|
|
|
|
|
|
|
|
virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner);
|
|
|
|
///< Handle a keyword token.
|
|
|
|
/// \return fetch another token?
|
|
|
|
|
|
|
|
virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner);
|
|
|
|
///< Handle a special character token.
|
|
|
|
/// \return fetch another token?
|
|
|
|
|
|
|
|
virtual void parseEOF (Scanner& scanner);
|
2014-02-14 11:23:00 +00:00
|
|
|
///< Handle EOF token.
|
|
|
|
|
2010-06-28 09:38:04 +00:00
|
|
|
void reset();
|
|
|
|
///< Reset parser to clean state.
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|