LCOV - code coverage report
Current view: top level - starmath/inc - parse.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 13 92.3 %
Date: 2015-06-13 12:38:46 Functions: 11 12 91.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : #ifndef INCLUDED_STARMATH_INC_PARSE_HXX
      20             : #define INCLUDED_STARMATH_INC_PARSE_HXX
      21             : 
      22             : #include <vcl/svapp.hxx>
      23             : 
      24             : #include <set>
      25             : 
      26             : #include "types.hxx"
      27             : #include "token.hxx"
      28             : #include "error.hxx"
      29             : #include "node.hxx"
      30             : 
      31        1202 : class SmParser
      32             : {
      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;
      45             : 
      46             :     // map of used symbols (used to reduce file size by exporting only actually used symbols)
      47             :     std::set< OUString >   m_aUsedSymbols;
      48             : 
      49             :     //! locale where '.' is decimal separator!
      50             :     ::com::sun::star::lang::Locale m_aDotLoc;
      51             : 
      52             :     SmParser(const SmParser&) SAL_DELETED_FUNCTION;
      53             :     SmParser& operator=(const SmParser&) SAL_DELETED_FUNCTION;
      54             : 
      55             : #if OSL_DEBUG_LEVEL > 1
      56             :     bool            IsDelimiter( const OUString &rTxt, sal_Int32 nPos );
      57             : #endif
      58             :     void            NextToken();
      59           0 :     sal_Int32       GetTokenIndex() const   { return m_nTokenIndex; }
      60             :     void            Replace( sal_Int32 nPos, sal_Int32 nLen, const OUString &rText );
      61             : 
      62             :     inline bool     TokenInGroup( sal_uLong nGroup );
      63             : 
      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
      95             : 
      96             :     LanguageType    GetLanguage() const { return m_nLang; }
      97        1776 :     void            SetLanguage( LanguageType nNewLang ) { m_nLang = nNewLang; }
      98             : 
      99             :     void    Error(SmParseError Error);
     100             : 
     101         910 :     void    ClearUsedSymbols()                              { m_aUsedSymbols.clear(); }
     102         131 :     void    AddToUsedSymbols( const OUString &rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); }
     103             : 
     104             : public:
     105             :                  SmParser();
     106             : 
     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);
     111             : 
     112         564 :     const OUString & GetText() const { return m_aBufferString; };
     113             : 
     114         136 :     bool        IsImportSymbolNames() const        { return bImportSymNames; }
     115          10 :     void        SetImportSymbolNames(bool bVal)    { bImportSymNames = bVal; }
     116         690 :     bool        IsExportSymbolNames() const        { return m_bExportSymNames; }
     117        1118 :     void        SetExportSymbolNames(bool bVal)    { m_bExportSymNames = bVal; }
     118             : 
     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         333 :     std::set< OUString >   GetUsedSymbols() const      { return m_aUsedSymbols; }
     126             : };
     127             : 
     128             : 
     129       48978 : inline bool SmParser::TokenInGroup( sal_uLong nGroup)
     130             : {
     131       48978 :     return (m_aCurToken.nGroup & nGroup) != 0;
     132             : }
     133             : 
     134             : 
     135             : #endif
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11