bump product version to 5.0.4.1
[LibreOffice.git] / starmath / inc / parse.hxx
blobfc40be80e4ca8b1eeb89edcd594f463414204fab
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 <vcl/svapp.hxx>
24 #include <set>
26 #include "types.hxx"
27 #include "token.hxx"
28 #include "error.hxx"
29 #include "node.hxx"
31 class SmParser
33 OUString m_aBufferString;
34 SmToken m_aCurToken;
35 SmNodeStack m_aNodeStack;
36 SmErrDescList m_aErrDescList;
37 int m_nCurError;
38 LanguageType m_nLang;
39 sal_Int32 m_nBufferIndex,
40 m_nTokenIndex;
41 sal_Int32 m_Row,
42 m_nColOff;
43 bool 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 ::com::sun::star::lang::Locale m_aDotLoc;
52 SmParser(const SmParser&) SAL_DELETED_FUNCTION;
53 SmParser& operator=(const SmParser&) SAL_DELETED_FUNCTION;
55 #if OSL_DEBUG_LEVEL > 1
56 bool IsDelimiter( const OUString &rTxt, sal_Int32 nPos );
57 #endif
58 void NextToken();
59 sal_Int32 GetTokenIndex() const { return m_nTokenIndex; }
60 void Replace( sal_Int32 nPos, sal_Int32 nLen, const OUString &rText );
62 inline bool TokenInGroup( sal_uLong nGroup );
64 // grammar
65 void Table();
66 void Line();
67 void Expression();
68 void Relation();
69 void Sum();
70 void Product();
71 void SubSup(sal_uLong nActiveGroup);
72 void OpSubSup();
73 void Power();
74 void Blank();
75 void Term(bool bGroupNumberIdent);
76 void Escape();
77 void Operator();
78 void Oper();
79 void UnOper();
80 void Align();
81 void FontAttribut();
82 void Attribut();
83 void Font();
84 void FontSize();
85 void Color();
86 void Brace();
87 void Bracebody(bool bIsLeftRight);
88 void Function();
89 void Binom();
90 void Stack();
91 void Matrix();
92 void Special();
93 void GlyphSpecial();
94 // end of grammar
96 LanguageType GetLanguage() const { return m_nLang; }
97 void SetLanguage( LanguageType nNewLang ) { m_nLang = nNewLang; }
99 void Error(SmParseError Error);
101 void ClearUsedSymbols() { m_aUsedSymbols.clear(); }
102 void AddToUsedSymbols( const OUString &rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); }
104 public:
105 SmParser();
107 /** Parse rBuffer to formula tree */
108 SmNode *Parse(const OUString &rBuffer);
109 /** Parse rBuffer to formula subtree that constitutes an expression */
110 SmNode *ParseExpression(const OUString &rBuffer);
112 const OUString & GetText() const { return m_aBufferString; };
114 bool IsImportSymbolNames() const { return bImportSymNames; }
115 void SetImportSymbolNames(bool bVal) { bImportSymNames = bVal; }
116 bool IsExportSymbolNames() const { return m_bExportSymNames; }
117 void SetExportSymbolNames(bool bVal) { m_bExportSymNames = bVal; }
119 size_t AddError(SmParseError Type, SmNode *pNode);
120 const SmErrorDesc* NextError();
121 const SmErrorDesc* PrevError();
122 const SmErrorDesc* GetError(size_t i);
123 static const SmTokenTableEntry* GetTokenTableEntry( const OUString &rName );
124 bool IsUsedSymbol( const OUString &rSymbolName ) const { return m_aUsedSymbols.find( rSymbolName ) != m_aUsedSymbols.end(); }
125 std::set< OUString > GetUsedSymbols() const { return m_aUsedSymbols; }
129 inline bool SmParser::TokenInGroup( sal_uLong nGroup)
131 return (m_aCurToken.nGroup & nGroup) != 0;
135 #endif
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */