OpenMW
|
00001 #ifndef COMPILER_EXPRPARSER_H_INCLUDED 00002 #define COMPILER_EXPRPARSER_H_INCLUDED 00003 00004 #include <vector> 00005 00006 #include <components/interpreter/types.hpp> 00007 00008 #include "parser.hpp" 00009 #include "tokenloc.hpp" 00010 00011 namespace Compiler 00012 { 00013 class Locals; 00014 class Literals; 00015 00016 class ExprParser : public Parser 00017 { 00018 Locals& mLocals; 00019 Literals& mLiterals; 00020 std::vector<char> mOperands; 00021 std::vector<char> mOperators; 00022 bool mNextOperand; 00023 TokenLoc mTokenLoc; 00024 std::vector<Interpreter::Type_Code> mCode; 00025 bool mFirst; 00026 bool mArgument; 00027 std::string mExplicit; 00028 bool mRefOp; 00029 bool mMemberOp; 00030 00031 int getPriority (char op) const; 00032 00033 char getOperandType (int Index = 0) const; 00034 00035 char getOperator() const; 00036 00037 bool isOpen() const; 00038 00039 void popOperator(); 00040 00041 void popOperand(); 00042 00043 void replaceBinaryOperands(); 00044 00045 void pop(); 00046 00047 void pushIntegerLiteral (int value); 00048 00049 void pushFloatLiteral (float value); 00050 00051 void pushBinaryOperator (char c); 00052 00053 void close(); 00054 00055 int parseArguments (const std::string& arguments, Scanner& scanner); 00056 00057 bool handleMemberAccess (const std::string& name); 00058 00059 public: 00060 00061 ExprParser (ErrorHandler& errorHandler, Context& context, Locals& locals, 00062 Literals& literals, bool argument = false); 00066 00067 char getType() const; 00069 00070 virtual bool parseInt (int value, const TokenLoc& loc, Scanner& scanner); 00073 00074 virtual bool parseFloat (float value, const TokenLoc& loc, Scanner& scanner); 00077 00078 virtual bool parseName (const std::string& name, const TokenLoc& loc, 00079 Scanner& scanner); 00082 00083 virtual bool parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner); 00086 00087 virtual bool parseSpecial (int code, const TokenLoc& loc, Scanner& scanner); 00090 00091 void reset(); 00093 00094 char append (std::vector<Interpreter::Type_Code>& code); 00097 00098 int parseArguments (const std::string& arguments, Scanner& scanner, 00099 std::vector<Interpreter::Type_Code>& code, bool invert = false); 00106 }; 00107 } 00108 00109 #endif