summaryrefslogtreecommitdiff
path: root/starmath/inc
diff options
context:
space:
mode:
authordante <dante19031999@gmail.com>2021-02-06 11:19:36 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-06 18:39:31 +0100
commit7c959884d9a4a3f187a79cbb01407cd20d92a2f8 (patch)
treeb82cf1081b55b320a0495130c01775fd6582a9e7 /starmath/inc
parent956c09ca7d690471f62e8e2e14ad04fefcebf7e7 (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')
-rw-r--r--starmath/inc/error.hxx56
-rw-r--r--starmath/inc/parse.hxx46
-rw-r--r--starmath/inc/strings.hrc1
3 files changed, 45 insertions, 58 deletions
diff --git a/starmath/inc/error.hxx b/starmath/inc/error.hxx
deleted file mode 100644
index dc798f6906e3..000000000000
--- a/starmath/inc/error.hxx
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef INCLUDED_STARMATH_INC_ERROR_HXX
-#define INCLUDED_STARMATH_INC_ERROR_HXX
-
-#include <rtl/ustring.hxx>
-
-class SmNode;
-
-// Those are the errors that the parser (parser.hxx/parser.cxx) may encounter.
-enum class SmParseError
-{
- None,
- UnexpectedChar,
- UnexpectedToken,
- PoundExpected,
- ColorExpected,
- LgroupExpected,
- RgroupExpected,
- LbraceExpected,
- RbraceExpected,
- ParentMismatch,
- RightExpected,
- FontExpected,
- SizeExpected,
- DoubleAlign,
- DoubleSubsupscript,
- NumberExpected
-};
-
-struct SmErrorDesc
-{
- SmParseError m_eType;
- SmNode* m_pNode;
- OUString m_aText;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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();
diff --git a/starmath/inc/strings.hrc b/starmath/inc/strings.hrc
index 01dc7b864ee4..daa90f02545d 100644
--- a/starmath/inc/strings.hrc
+++ b/starmath/inc/strings.hrc
@@ -374,6 +374,7 @@
#define STR_STATSTR_WRITING NC_("STR_STATSTR_WRITING", "Saving document..." )
#define STR_MATH_DOCUMENT_FULLTYPE_CURRENT NC_("STR_MATH_DOCUMENT_FULLTYPE_CURRENT", "%PRODUCTNAME %PRODUCTVERSION Formula")
#define RID_ERR_IDENT NC_("RID_ERR_IDENT", "ERROR : " )
+#define RID_ERR_NONE NC_("RID_ERR_NONE", "no error" )
#define RID_ERR_UNEXPECTEDCHARACTER NC_("RID_ERR_UNEXPECTEDCHARACTER", "Unexpected character" )
#define RID_ERR_UNEXPECTEDTOKEN NC_("RID_ERR_UNEXPECTEDTOKEN", "Unexpected token" )
#define RID_ERR_LGROUPEXPECTED NC_("RID_ERR_LGROUPEXPECTED", "'{' expected" )