| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #ifndef MU_PARSER_TOKEN_READER_H |
| | #define MU_PARSER_TOKEN_READER_H |
| |
|
| | #include <cstdio> |
| | #include <cstring> |
| | #include <list> |
| | #include <map> |
| | #include <memory> |
| | #include <stack> |
| | #include <string> |
| |
|
| | #include "muParserDef.h" |
| | #include "muParserToken.h" |
| |
|
| | |
| | |
| | |
| |
|
| |
|
| | namespace mu |
| | { |
| | |
| | class ParserBase; |
| |
|
| | |
| | class API_EXPORT_CXX ParserTokenReader final |
| | { |
| | private: |
| |
|
| | typedef ParserToken<value_type, string_type> token_type; |
| |
|
| | public: |
| |
|
| | ParserTokenReader(ParserBase* a_pParent); |
| | ParserTokenReader* Clone(ParserBase* a_pParent) const; |
| |
|
| | void AddValIdent(identfun_type a_pCallback); |
| | void SetVarCreator(facfun_type a_pFactory, void* pUserData); |
| | void SetFormula(const string_type& a_strFormula); |
| | void SetArgSep(char_type cArgSep); |
| |
|
| | |
| | |
| | |
| | |
| | bool HasVarCreator() const |
| | { |
| | return m_pFactory != nullptr; |
| | } |
| |
|
| | int GetPos() const; |
| | const string_type& GetExpr() const; |
| | varmap_type& GetUsedVar(); |
| | char_type GetArgSep() const; |
| |
|
| | void IgnoreUndefVar(bool bIgnore); |
| | void ReInit(); |
| | token_type ReadNextToken(); |
| |
|
| | private: |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | enum ESynCodes |
| | { |
| | noBO = 1 << 0, |
| | noBC = 1 << 1, |
| | noVAL = 1 << 2, |
| | noVAR = 1 << 3, |
| | noARG_SEP = 1 << 4, |
| | noFUN = 1 << 5, |
| | noOPT = 1 << 6, |
| | noPOSTOP = 1 << 7, |
| | noINFIXOP = 1 << 8, |
| | noEND = 1 << 9, |
| | noSTR = 1 << 10, |
| | noASSIGN = 1 << 11, |
| | noIF = 1 << 12, |
| | noELSE = 1 << 13, |
| | sfSTART_OF_LINE = noOPT | noBC | noPOSTOP | noASSIGN | noIF | noELSE | noARG_SEP, |
| | noANY = ~0 |
| | }; |
| |
|
| | ParserTokenReader(const ParserTokenReader& a_Reader); |
| | ParserTokenReader& operator=(const ParserTokenReader& a_Reader); |
| | void Assign(const ParserTokenReader& a_Reader); |
| |
|
| | void SetParent(ParserBase* a_pParent); |
| | int ExtractToken(const char_type* a_szCharSet, string_type& a_strTok, std::size_t a_iPos) const; |
| | int ExtractOperatorToken(string_type& a_sTok, std::size_t a_iPos) const; |
| |
|
| | bool IsBuiltIn(token_type& a_Tok); |
| | bool IsArgSep(token_type& a_Tok); |
| | bool IsEOF(token_type& a_Tok); |
| | bool IsInfixOpTok(token_type& a_Tok); |
| | bool IsFunTok(token_type& a_Tok); |
| | bool IsPostOpTok(token_type& a_Tok); |
| | bool IsOprt(token_type& a_Tok); |
| | bool IsValTok(token_type& a_Tok); |
| | bool IsVarTok(token_type& a_Tok); |
| | bool IsStrVarTok(token_type& a_Tok); |
| | bool IsUndefVarTok(token_type& a_Tok); |
| | bool IsString(token_type& a_Tok); |
| | void Error(EErrorCodes a_iErrc, int a_iPos = -1, const string_type& a_sTok = string_type()) const; |
| |
|
| | token_type& SaveBeforeReturn(const token_type& tok); |
| |
|
| | ParserBase* m_pParser; |
| | string_type m_strFormula; |
| | int m_iPos; |
| | int m_iSynFlags; |
| | bool m_bIgnoreUndefVar; |
| |
|
| | const funmap_type* m_pFunDef; |
| | const funmap_type* m_pPostOprtDef; |
| | const funmap_type* m_pInfixOprtDef; |
| | const funmap_type* m_pOprtDef; |
| | const valmap_type* m_pConstDef; |
| | const strmap_type* m_pStrVarDef; |
| |
|
| | varmap_type* m_pVarDef; |
| | facfun_type m_pFactory; |
| | void* m_pFactoryData; |
| | std::list<identfun_type> m_vIdentFun; |
| | varmap_type m_UsedVar; |
| | value_type m_fZero; |
| | |
| | std::stack<int> m_bracketStack; |
| |
|
| | token_type m_lastTok; |
| | char_type m_cArgSep; |
| | }; |
| | } |
| |
|
| | #endif |
| |
|
| |
|
| |
|