build fix
[LibreOffice.git] / starmath / inc / parse.hxx
blobd22a426519fed0b2a6bd8b4c414d01a13cce4776
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_STARMATH_INC_PARSE_HXX
20 #define INCLUDED_STARMATH_INC_PARSE_HXX
22 #include <com/sun/star/lang/Locale.hpp>
23 #include <memory>
24 #include <set>
25 #include <vector>
27 #include "types.hxx"
28 #include "token.hxx"
29 #include "error.hxx"
30 #include "node.hxx"
32 class SmParser
34 OUString m_aBufferString;
35 SmToken m_aCurToken;
36 SmNodeStack m_aNodeStack;
37 std::vector<std::unique_ptr<SmErrorDesc>> m_aErrDescList;
38 int m_nCurError;
39 sal_Int32 m_nBufferIndex,
40 m_nTokenIndex;
41 sal_Int32 m_nRow, // 1-based
42 m_nColOff; // 0-based
43 bool m_bImportSymNames,
44 m_bExportSymNames;
46 // map of used symbols (used to reduce file size by exporting only actually used symbols)
47 std::set< OUString > m_aUsedSymbols;
49 //! locale where '.' is decimal separator!
50 css::lang::Locale m_aDotLoc;
52 SmParser(const SmParser&) = delete;
53 SmParser& operator=(const SmParser&) = delete;
55 void NextToken();
56 sal_Int32 GetTokenIndex() const { return m_nTokenIndex; }
57 void Replace( sal_Int32 nPos, sal_Int32 nLen, const OUString &rText );
59 inline bool TokenInGroup( TG nGroup );
61 // grammar
62 SmTableNode *DoTable();
63 void DoLine();
64 void DoExpression();
65 void DoRelation();
66 void DoSum();
67 void DoProduct();
68 void DoSubSup(TG nActiveGroup);
69 void DoOpSubSup();
70 void DoPower();
71 void DoBlank();
72 void DoTerm(bool bGroupNumberIdent);
73 void DoEscape();
74 void DoOperator();
75 void DoOper();
76 void DoUnOper();
77 void DoAlign();
78 void DoFontAttribut();
79 void DoAttribut();
80 void DoFont();
81 void DoFontSize();
82 void DoColor();
83 void DoBrace();
84 void DoBracebody(bool bIsLeftRight);
85 void DoFunction();
86 void DoBinom();
87 void DoStack();
88 void DoMatrix();
89 void DoSpecial();
90 void DoGlyphSpecial();
91 // end of grammar
93 void Error(SmParseError Error);
95 public:
96 SmParser();
98 /** Parse rBuffer to formula tree */
99 SmTableNode *Parse(const OUString &rBuffer);
100 /** Parse rBuffer to formula subtree that constitutes an expression */
101 SmNode *ParseExpression(const OUString &rBuffer);
103 const OUString & GetText() const { return m_aBufferString; };
105 bool IsImportSymbolNames() const { return m_bImportSymNames; }
106 void SetImportSymbolNames(bool bVal) { m_bImportSymNames = bVal; }
107 bool IsExportSymbolNames() const { return m_bExportSymNames; }
108 void SetExportSymbolNames(bool bVal) { m_bExportSymNames = bVal; }
110 void AddError(SmParseError Type, SmNode *pNode);
111 const SmErrorDesc* NextError();
112 const SmErrorDesc* PrevError();
113 const SmErrorDesc* GetError(size_t i);
114 static const SmTokenTableEntry* GetTokenTableEntry( const OUString &rName );
115 const std::set< OUString >& GetUsedSymbols() const { return m_aUsedSymbols; }
119 inline bool SmParser::TokenInGroup( TG nGroup)
121 return bool(m_aCurToken.nGroup & nGroup);
125 #endif
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */