21#ifndef __LIBEVAL_COMPILER_H
22#define __LIBEVAL_COMPILER_H
38#define TR_OP_BINARY_MASK 0x200
39#define TR_OP_UNARY_MASK 0x100
41#define TR_OP_MUL 0x201
42#define TR_OP_DIV 0x202
43#define TR_OP_ADD 0x203
44#define TR_OP_SUB 0x204
45#define TR_OP_LESS 0x205
46#define TR_OP_GREATER 0x206
47#define TR_OP_LESS_EQUAL 0x207
48#define TR_OP_GREATER_EQUAL 0x208
49#define TR_OP_EQUAL 0x209
50#define TR_OP_NOT_EQUAL 0x20a
51#define TR_OP_BOOL_AND 0x20b
52#define TR_OP_BOOL_OR 0x20c
53#define TR_OP_BOOL_NOT 0x100
54#define TR_OP_FUNC_CALL 24
55#define TR_OP_METHOD_CALL 25
56#define TR_UOP_PUSH_VAR 1
57#define TR_UOP_PUSH_VALUE 2
144 void SetUop(
int aOp,
double aValue );
145 void SetUop(
int aOp,
const wxString& aValue,
bool aStringIsWildcard );
146 void SetUop(
int aOp, std::unique_ptr<VAR_REF> aRef =
nullptr );
167 static const std::vector<wxString> nullUnits;
174 return wxEmptyString;
177 virtual double Convert(
const wxString& aString,
int unitType )
const
195 VALUE(
const wxString& aStr,
bool aIsWildcard =
false ) :
264 void Set(
const wxString& aValue )
354 void SetErrorCallback( std::function<
void(
const wxString& aMessage,
int aOffset )> aCallback )
383 wxString
Dump()
const;
385 virtual std::unique_ptr<VAR_REF>
CreateVarRef(
const wxString& var,
const wxString& field )
404 UOP(
int op, std::unique_ptr<VALUE> value ) :
410 UOP(
int op, std::unique_ptr<VAR_REF> vref ) :
477 wxString
GetChars(
const std::function<
bool( wxUniChar )>& cond )
const;
480 const std::function<
bool( wxUniChar )>& stopCond )
const;
511 void SetErrorCallback( std::function<
void(
const wxString& aMessage,
int aOffset )> aCallback )
536 void newString(
const wxString& aString );
void SetErrorCallback(std::function< void(const wxString &aMessage, int aOffset)> aCallback)
bool IsErrorPending() const
std::unique_ptr< UNIT_RESOLVER > m_unitResolver
void newString(const wxString &aString)
void GcItem(wxString *aItem)
void freeTree(LIBEVAL::TREE_NODE *tree)
bool lexString(T_TOKEN &aToken)
void GcItem(TREE_NODE *aItem)
bool generateUCode(UCODE *aCode, CONTEXT *aPreflightContext)
char m_localeDecimalSeparator
std::function< void(const wxString &aMessage, int aOffset)> m_errorCallback
bool lexDefault(T_TOKEN &aToken)
std::vector< TREE_NODE * > m_gcItems
void reportError(COMPILATION_STAGE stage, const wxString &aErrorMsg, int aPos=-1)
const ERROR_STATUS & GetError() const
void setRoot(LIBEVAL::TREE_NODE *root)
std::vector< wxString * > m_gcStrings
bool Compile(const wxString &aString, UCODE *aCode, CONTEXT *aPreflightContext)
ERROR_STATUS m_errorStatus
void parseError(const char *s)
std::vector< VALUE * > m_ownedValues
VALUE * StoreValue(VALUE *aValue)
void ReportError(const wxString &aErrorMsg)
std::function< void(const wxString &aMessage, int aOffset)> m_errorCallback
void SetErrorCallback(std::function< void(const wxString &aMessage, int aOffset)> aCallback)
void NextChar(int aAdvance=1)
void Restart(const wxString &aStr)
wxString GetChars(const std::function< bool(wxUniChar)> &cond) const
bool MatchAhead(const wxString &match, const std::function< bool(wxUniChar)> &stopCond) const
void SetUop(int aOp, double aValue)
virtual std::unique_ptr< VAR_REF > CreateVarRef(const wxString &var, const wxString &field)
std::vector< UOP * > m_ucode
VALUE * Run(CONTEXT *ctx)
virtual FUNC_CALL_REF CreateFuncCall(const wxString &name)
virtual wxString GetSupportedUnitsMessage() const
virtual double Convert(const wxString &aString, int unitType) const
virtual const std::vector< wxString > & GetSupportedUnits() const
UOP(int op, FUNC_CALL_REF func, std::unique_ptr< VAR_REF > vref=nullptr)
std::unique_ptr< VAR_REF > m_ref
UOP(int op, std::unique_ptr< VALUE > value)
std::unique_ptr< VALUE > m_value
UOP(int op, std::unique_ptr< VAR_REF > vref)
virtual const wxString & AsString() const
void SetDeferredEval(std::function< wxString()> aLambda)
void Set(const wxString &aValue)
virtual bool NotEqualTo(CONTEXT *aCtx, const VALUE *b) const
std::function< double()> m_lambdaDbl
virtual double AsDouble() const
VAR_TYPE_T GetType() const
void Set(const VALUE &val)
virtual bool EqualTo(CONTEXT *aCtx, const VALUE *b) const
void SetDeferredEval(std::function< double()> aLambda)
std::function< wxString()> m_lambdaStr
VALUE(const wxString &aStr, bool aIsWildcard=false)
virtual VALUE * GetValue(CONTEXT *aCtx)=0
virtual VAR_TYPE_T GetType() const =0
TREE_NODE * newNode(LIBEVAL::COMPILER *compiler, int op, const T_TOKEN_VALUE &value)
constexpr T_TOKEN defaultToken
constexpr T_TOKEN_VALUE defaultTokenValue
std::function< void(CONTEXT *, void *)> FUNC_CALL_REF