diff options
author | dante <dante19031999@gmail.com> | 2021-02-06 11:19:36 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-06 18:39:31 +0100 |
commit | 7c959884d9a4a3f187a79cbb01407cd20d92a2f8 (patch) | |
tree | b82cf1081b55b320a0495130c01775fd6582a9e7 /starmath/inc/parse.hxx | |
parent | 956c09ca7d690471f62e8e2e14ad04fefcebf7e7 (diff) |
Modifications on starmath smparse error handle
Made modifications for:
- Being able to highlight syntax errors
- Displaying error description in visual editor
- Easier constructor
- Rely on starmathdatabase instead of long switch in code.
Change-Id: Ic6c7f920463090176d80668f9b660ccf3e9b5708
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110497
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/inc/parse.hxx')
-rw-r--r-- | starmath/inc/parse.hxx | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index b010db941832..6eb83500b3d3 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -30,7 +30,6 @@ #include <vector> #include "token.hxx" -#include "error.hxx" class SmBlankNode; class SmBinVerNode; @@ -46,6 +45,50 @@ class SmTextNode; #define DEPTH_LIMIT 1024 +// Those are the errors that the parser may encounter. +enum class SmParseError : uint_fast8_t +{ + None = 0, + UnexpectedChar = 1, + UnexpectedToken = 2, + PoundExpected = 3, + ColorExpected = 4, + LgroupExpected = 5, + RgroupExpected = 6, + LbraceExpected = 7, + RbraceExpected = 8, + ParentMismatch = 9, + RightExpected = 10, + FontExpected = 11, + SizeExpected = 12, + DoubleAlign = 13, + DoubleSubsupscript = 14, + NumberExpected = 15 +}; + +struct SmErrorDesc +{ + SmParseError m_eType; + SmNode* m_pNode; + OUString m_aText; + + SmErrorDesc(SmParseError eType, SmNode* pNode, OUString aText) + : m_eType(eType) + , m_pNode(pNode) + , m_aText(aText) + {} + +}; + +namespace starmathdatabase{ + +// Must be in sync with SmParseError list +extern const char* SmParseErrorDesc[16]; + +OUString getParseErrorDesc(SmParseError err); + +} + class SmParser { OUString m_aBufferString; @@ -148,7 +191,6 @@ public: bool IsExportSymbolNames() const { return m_bExportSymNames; } void SetExportSymbolNames(bool bVal) { m_bExportSymNames = bVal; } - void AddError(SmParseError Type, SmNode *pNode); const SmErrorDesc* NextError(); const SmErrorDesc* PrevError(); const SmErrorDesc* GetError(); |