1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-04 02:41:19 +00:00
OpenMW/components/compiler/fileparser.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.5 KiB
C++
Raw Normal View History

2010-06-27 17:20:21 +00:00
#ifndef COMPILER_FILEPARSER_H_INCLUDED
#define COMPILER_FILEPARSER_H_INCLUDED
#include "locals.hpp"
2010-06-27 17:20:21 +00:00
#include "parser.hpp"
#include "scriptparser.hpp"
2010-06-27 17:20:21 +00:00
namespace Compiler
{
// Top-level parser, to be used for global scripts, local scripts and targeted scripts
2022-09-22 18:26:05 +00:00
2010-06-27 17:20:21 +00:00
class FileParser : public Parser
{
enum State
{
BeginState,
NameState,
BeginCompleteState,
EndNameState,
EndCompleteState
};
2022-09-22 18:26:05 +00:00
ScriptParser mScriptParser;
State mState;
std::string mName;
Locals mLocals;
2022-09-22 18:26:05 +00:00
2010-06-27 17:20:21 +00:00
public:
FileParser(ErrorHandler& errorHandler, Context& context);
2022-09-22 18:26:05 +00:00
std::string getName() const;
///< Return script name.
2022-09-22 18:26:05 +00:00
Interpreter::Program getProgram() const;
2022-09-22 18:26:05 +00:00
const Locals& getLocals() const;
///< get local variable declarations.
2022-09-22 18:26:05 +00:00
bool parseName(const std::string& name, const TokenLoc& loc, Scanner& scanner) override;
2010-06-27 17:20:21 +00:00
///< Handle a name token.
/// \return fetch another token?
2022-09-22 18:26:05 +00:00
bool parseKeyword(int keyword, const TokenLoc& loc, Scanner& scanner) override;
2010-06-27 17:20:21 +00:00
///< Handle a keyword token.
/// \return fetch another token?
2022-09-22 18:26:05 +00:00
bool parseSpecial(int code, const TokenLoc& loc, Scanner& scanner) override;
2010-06-27 17:20:21 +00:00
///< Handle a special character token.
/// \return fetch another token?
2022-09-22 18:26:05 +00:00
void parseEOF(Scanner& scanner) override;
2010-06-27 17:20:21 +00:00
///< Handle EOF token.
2022-09-22 18:26:05 +00:00
void reset() override;
///< Reset parser to clean state.
2010-06-27 17:20:21 +00:00
};
}
#endif