1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
34 OUString m_aBufferString
;
36 SmNodeStack m_aNodeStack
;
37 std::vector
<std::unique_ptr
<SmErrorDesc
>> m_aErrDescList
;
39 sal_Int32 m_nBufferIndex
,
41 sal_Int32 m_nRow
, // 1-based
43 bool m_bImportSymNames
,
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;
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
);
62 SmTableNode
*DoTable();
68 void DoSubSup(TG nActiveGroup
);
72 void DoTerm(bool bGroupNumberIdent
);
78 void DoFontAttribut();
84 void DoBracebody(bool bIsLeftRight
);
90 void DoGlyphSpecial();
93 void Error(SmParseError Error
);
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
);
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */