2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-04 15:25:45 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2013-10-22 21:30:16 +02:00
|
|
|
#ifndef INCLUDED_STARMATH_INC_PARSE_HXX
|
|
|
|
#define INCLUDED_STARMATH_INC_PARSE_HXX
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-04-18 07:54:29 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2010-10-13 11:39:15 +02:00
|
|
|
#include <set>
|
2015-08-03 14:03:54 +02:00
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
2010-10-13 11:39:15 +02:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "types.hxx"
|
2014-11-09 00:14:29 +09:00
|
|
|
#include "token.hxx"
|
|
|
|
#include "error.hxx"
|
|
|
|
#include "node.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-03-10 18:19:05 +09:00
|
|
|
class SmParser
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-09-04 17:09:22 +02:00
|
|
|
OUString m_aBufferString;
|
2010-10-13 11:39:15 +02:00
|
|
|
SmToken m_aCurToken;
|
|
|
|
SmNodeStack m_aNodeStack;
|
2015-08-03 14:03:54 +02:00
|
|
|
boost::ptr_vector< SmErrorDesc > m_aErrDescList;
|
2010-10-13 11:39:15 +02:00
|
|
|
int m_nCurError;
|
|
|
|
LanguageType m_nLang;
|
2013-09-04 17:09:22 +02:00
|
|
|
sal_Int32 m_nBufferIndex,
|
2010-10-13 11:39:15 +02:00
|
|
|
m_nTokenIndex;
|
2013-09-04 17:09:22 +02:00
|
|
|
sal_Int32 m_Row,
|
2010-10-13 11:39:15 +02:00
|
|
|
m_nColOff;
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bImportSymNames,
|
2010-10-13 11:39:15 +02:00
|
|
|
m_bExportSymNames;
|
|
|
|
|
|
|
|
// map of used symbols (used to reduce file size by exporting only actually used symbols)
|
2013-04-07 12:06:47 +02:00
|
|
|
std::set< OUString > m_aUsedSymbols;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-05-15 10:42:04 +03:00
|
|
|
//! locale where '.' is decimal separator!
|
2011-05-31 21:50:51 +01:00
|
|
|
::com::sun::star::lang::Locale m_aDotLoc;
|
|
|
|
|
2015-03-10 18:19:05 +09:00
|
|
|
SmParser(const SmParser&) SAL_DELETED_FUNCTION;
|
|
|
|
SmParser& operator=(const SmParser&) SAL_DELETED_FUNCTION;
|
|
|
|
|
2011-08-04 21:18:00 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2013-09-04 17:09:22 +02:00
|
|
|
bool IsDelimiter( const OUString &rTxt, sal_Int32 nPos );
|
2004-08-11 14:06:33 +00:00
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
void NextToken();
|
2013-09-04 17:09:22 +02:00
|
|
|
sal_Int32 GetTokenIndex() const { return m_nTokenIndex; }
|
|
|
|
void Replace( sal_Int32 nPos, sal_Int32 nLen, const OUString &rText );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
inline bool TokenInGroup( sal_uLong nGroup );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// grammar
|
2015-06-14 21:18:11 +01:00
|
|
|
void DoTable();
|
|
|
|
void DoLine();
|
|
|
|
void DoExpression();
|
|
|
|
void DoRelation();
|
|
|
|
void DoSum();
|
|
|
|
void DoProduct();
|
|
|
|
void DoSubSup(sal_uLong nActiveGroup);
|
|
|
|
void DoOpSubSup();
|
|
|
|
void DoPower();
|
|
|
|
void DoBlank();
|
|
|
|
void DoTerm(bool bGroupNumberIdent);
|
|
|
|
void DoEscape();
|
|
|
|
void DoOperator();
|
|
|
|
void DoOper();
|
|
|
|
void DoUnOper();
|
|
|
|
void DoAlign();
|
|
|
|
void DoFontAttribut();
|
|
|
|
void DoAttribut();
|
|
|
|
void DoFont();
|
|
|
|
void DoFontSize();
|
|
|
|
void DoColor();
|
|
|
|
void DoBrace();
|
|
|
|
void DoBracebody(bool bIsLeftRight);
|
|
|
|
void DoFunction();
|
|
|
|
void DoBinom();
|
|
|
|
void DoStack();
|
|
|
|
void DoMatrix();
|
|
|
|
void DoSpecial();
|
|
|
|
void DoGlyphSpecial();
|
2000-09-18 16:07:07 +00:00
|
|
|
// end of grammar
|
|
|
|
|
2010-10-13 11:39:15 +02:00
|
|
|
void SetLanguage( LanguageType nNewLang ) { m_nLang = nNewLang; }
|
2001-12-14 08:07:32 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void Error(SmParseError Error);
|
|
|
|
|
2010-10-13 11:39:15 +02:00
|
|
|
void ClearUsedSymbols() { m_aUsedSymbols.clear(); }
|
2013-09-04 17:09:22 +02:00
|
|
|
void AddToUsedSymbols( const OUString &rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); }
|
2010-10-13 11:39:15 +02:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
public:
|
|
|
|
SmParser();
|
|
|
|
|
2010-10-01 22:04:50 +02:00
|
|
|
/** Parse rBuffer to formula tree */
|
2013-09-04 17:09:22 +02:00
|
|
|
SmNode *Parse(const OUString &rBuffer);
|
2010-10-01 22:04:50 +02:00
|
|
|
/** Parse rBuffer to formula subtree that constitutes an expression */
|
2012-09-25 21:17:31 +04:00
|
|
|
SmNode *ParseExpression(const OUString &rBuffer);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-09-04 17:09:22 +02:00
|
|
|
const OUString & GetText() const { return m_aBufferString; };
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-12-12 06:59:49 -08:00
|
|
|
bool IsImportSymbolNames() const { return bImportSymNames; }
|
|
|
|
void SetImportSymbolNames(bool bVal) { bImportSymNames = bVal; }
|
2011-03-14 16:51:14 +00:00
|
|
|
bool IsExportSymbolNames() const { return m_bExportSymNames; }
|
|
|
|
void SetExportSymbolNames(bool bVal) { m_bExportSymNames = bVal; }
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-12-12 06:59:49 -08:00
|
|
|
size_t AddError(SmParseError Type, SmNode *pNode);
|
|
|
|
const SmErrorDesc* NextError();
|
|
|
|
const SmErrorDesc* PrevError();
|
2014-12-16 18:44:10 +09:00
|
|
|
const SmErrorDesc* GetError(size_t i);
|
2013-09-04 17:09:22 +02:00
|
|
|
static const SmTokenTableEntry* GetTokenTableEntry( const OUString &rName );
|
2013-04-07 12:06:47 +02:00
|
|
|
std::set< OUString > GetUsedSymbols() const { return m_aUsedSymbols; }
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
inline bool SmParser::TokenInGroup( sal_uLong nGroup)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-04-24 12:33:33 +02:00
|
|
|
return (m_aCurToken.nGroup & nGroup) != 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|