| |
| |
| #ifndef TPARSER_INCLUDED |
| #define TPARSER_INCLUDED |
| |
| #include "tcommon.h" |
| #include "tgrammar.h" |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TNZBASE_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| namespace TSyntax |
| { |
| |
| struct DVAPI SyntaxToken { |
| int m_pos, m_length; |
| TokenType m_type; |
| }; |
| |
| class DVAPI Parser |
| { |
| class Imp; |
| Imp *m_imp; |
| |
| public: |
| Parser(const Grammar *grammar); |
| ~Parser(); |
| |
| |
| |
| Calculator *parse(string text); |
| |
| |
| bool isValid() const; |
| |
| |
| string getText() const; |
| |
| |
| string getError() const; |
| |
| |
| |
| std::pair<int, int> getErrorPos() const; |
| |
| enum SyntaxStatus { |
| Correct, |
| Incomplete, |
| Error, |
| ExtraIgnored |
| }; |
| SyntaxStatus checkSyntax(std::vector<SyntaxToken> &tokens, string text); |
| |
| void getSuggestions(Grammar::Suggestions &suggestions, string text); |
| string getCurrentPatternString(string text); |
| |
| private: |
| |
| Parser(const Parser &); |
| Parser &operator=(const Parser &); |
| }; |
| |
| } |
| |
| #endif |
| |