OpenMW
|
00001 #ifndef COMPILER_FILEPARSER_H_INCLUDED 00002 #define COMPILER_FILEPARSER_H_INCLUDED 00003 00004 #include "parser.hpp" 00005 #include "scriptparser.hpp" 00006 #include "locals.hpp" 00007 #include "literals.hpp" 00008 00009 namespace Compiler 00010 { 00011 // Top-level parser, to be used for global scripts, local scripts and targeted scripts 00012 00013 class FileParser : public Parser 00014 { 00015 enum State 00016 { 00017 BeginState, NameState, BeginCompleteState, EndNameState, 00018 EndCompleteState 00019 }; 00020 00021 ScriptParser mScriptParser; 00022 State mState; 00023 std::string mName; 00024 Locals mLocals; 00025 00026 public: 00027 00028 FileParser (ErrorHandler& errorHandler, Context& context); 00029 00030 std::string getName() const; 00032 00033 void getCode (std::vector<Interpreter::Type_Code>& code) const; 00035 00036 const Locals& getLocals() const; 00038 00039 virtual bool parseName (const std::string& name, const TokenLoc& loc, 00040 Scanner& scanner); 00043 00044 virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner); 00047 00048 virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner); 00051 00052 virtual void parseEOF (Scanner& scanner); 00054 00055 void reset(); 00057 }; 00058 } 00059 00060 #endif