OpenMW
components/compiler/lineparser.hpp
Go to the documentation of this file.
00001 #ifndef COMPILER_LINEPARSER_H_INCLUDED
00002 #define COMPILER_LINEPARSER_H_INCLUDED
00003 
00004 #include <vector>
00005 
00006 #include <components/interpreter/types.hpp>
00007 
00008 #include "parser.hpp"
00009 #include "exprparser.hpp"
00010 
00011 namespace Compiler
00012 {
00013     class Locals;
00014     class Literals;
00015 
00017 
00018     class LineParser : public Parser
00019     {
00020             enum State
00021             {
00022                 BeginState,
00023                 ShortState, LongState, FloatState,
00024                 SetState, SetLocalVarState, SetGlobalVarState, SetPotentialMemberVarState,
00025                 SetMemberVarState, SetMemberVarState2,
00026                 MessageState, MessageCommaState, MessageButtonState, MessageButtonCommaState,
00027                 EndState,
00028                 PotentialExplicitState, ExplicitState, MemberState
00029             };
00030 
00031             Locals& mLocals;
00032             Literals& mLiterals;
00033             std::vector<Interpreter::Type_Code>& mCode;
00034             State mState;
00035             std::string mName;
00036             std::string mMemberName;
00037             int mButtons;
00038             std::string mExplicit;
00039             char mType;
00040             ExprParser mExprParser;
00041             bool mAllowExpression;
00042 
00043             void parseExpression (Scanner& scanner, const TokenLoc& loc);
00044 
00045         public:
00046 
00047             LineParser (ErrorHandler& errorHandler, Context& context, Locals& locals,
00048                 Literals& literals, std::vector<Interpreter::Type_Code>& code,
00049                 bool allowExpression = false);
00052 
00053             virtual bool parseInt (int value, const TokenLoc& loc, Scanner& scanner);
00056 
00057             virtual bool parseFloat (float value, const TokenLoc& loc, Scanner& scanner);
00060 
00061             virtual bool parseName (const std::string& name, const TokenLoc& loc,
00062                 Scanner& scanner);
00065 
00066             virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner);
00069 
00070             virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner);
00073 
00074             void reset();
00076     };
00077 }
00078 
00079 #endif