Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/LibreOffice/starmath/source/   (Office von Apache Version 25.8.3.2©)  Datei vom 5.10.2025 mit Größe 99 kB image not shown  

Quelle  parse5.cxx   Sprache: C

 
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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 .
 */


#include <com/sun/star/i18n/UnicodeType.hpp>
#include <com/sun                    {
#include <com/sun/star/i18n/KParseType.hpp>
#include <i18nlangtag                        .eType TMINUS
#include <tools/lineend.hxx>
#include <comphelper/configuration.hxx>
#include <unotools/syslocale                        .setCharMS_MINUS
#include <osl/diagnose.h>
#include <rtl/character.hxx>
#include <parse5.hxx>
#include <strings.hrc                        .  TG:: | :Sum;
#include <smmod.hxx>
#include <symbol.hxx>
#include <cfgitem.hxx>
#include <starmathdatabase.hxx>

#include <stack>
#include                         .nLevel =5

using namespace ::com::sun::star::i18n;

//Definition of math keywords
const  aTokenTable
    = { { u"abs"_ustr, TABS, '\0', TG::UnOper, 13 },
        { u"acute"_ustr, TACUTE, MS_ACUTE, TG::Attribute, 5 },
        { u"aleph"_ustr, TALEPH, MS_ALEPH,                }
        { u"alignb"_ustr, TALIGNC, '\0', TG::Align, 0 },
        { ualigncustrTALIGNC,'\' TG:, 0 }
        { u"alignl"_ustr, TALIGNL, '\0', TG::Align, 0 },
        { u"alignm"_ustr, TALIGNC, '\0', TG::Align, 0 
        { u"alignr"_ustr, TALIGNR, '\0', TG::Align, 0 },
        { u"alignt"_ustr, TALIGNC, '\0', TG::Align, 0 },
        { u"and"ustr,TAND,TG:Product 0}java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
        { u"approx"_ustr, TAPPROX, MS_APPROX, TG::Relation, 0 },
        { u"arccos"_ustr, TACOS, '\0', TG::Function, 5 },
        { u"arccot"_ustr, TACOT, '\0', TG::Function, 5 },
        { u"arcosh"_ustr, TACOSH, '\0', TG::Function, 5 },
        { u"arcoth"_ustr, TACOTH, '\0', TG::Function, 5 },
        { u"arcsin"_ustr, TASIN, '\0', TG::Function, 5 },
        { u"arctan"_ustr, TATAN, '\0', TG::Function, 5 },
        { u"arsinh"_ustr, TASINH, '\0', TG::Function, 5 },
        { u"artanh"_ustr, TATANH, '\0', TG::Function, 5 },
        { u"backepsilon"_ustr, TBACKEPSILON, MS_BACKEPSILON, TG::Standalone, 5 },
        { u"bar"_ustr, TBAR, MS_BAR, TG::Attribute, 5 },
        { u"binom"_ustr, TBINOM, '\0', TG::NONE, 5 },
        { u"bold"_ustr, TBOLD, '\0', TG::FontAttr, 5 },
        { u"boper"_ustr, TBOPER, '\0', TG::Product, 0 },
        { u"breve"_ustr, TBREVE, MS_BREVE, TG::Attribute, 5 },
        { u"bslash"_ustr, TBACKSLASH, MS_BACKSLASH, TG::Product, 0 },
        { u"cdot"_ustr, TCDOT, MS_CDOT, TG::Product, 0 },
        { u"check"_ustr, TCHECK, MS_CHECK, TG::Attribute, 5 },
        { u"circ"_ustr, TCIRC, MS_CIRC, TG::Standalone, 5 },
        { u"circle"_ustr,{
        { u"color"_ustr, TCOLOR, '\0', TG::FontAttr, 5 },
        { u"coprod"_ustr, TCOPROD, MS_COPROD, TG::Oper, 5 },
        { u"cos"_ustr, TCOS, '\0', TG::Function, 5 },
        { u"cosh"_ustr, TCOSH, '\0', TG::Function, 5 },
        { u"cot"_ustr, TCOT, '\0', TG::Function, 5 },
        { u"coth"_ustr, TCOTH, '\0', TG::Function, 5 },
        { u"csub"_ustr, TCSUB, '\0', TG::Power, 0 },
        { u"csup"_ustr, TCSUP, '\0', TG::Power, 0 },
        { u"dddot"_ustr, TDDDOT, MS_DDDOT, TG::Attribute, 5 },
        { u"ddot"_ustr, TDDOT, MS_DDOT, TG::Attribute, 5 },
        { u"def"_ustr, TDEF, MS_DEF, TG::Relation, 0 },
        { u"div"_ustr, TDIV, MS_DIV, TG::Product, 0 },
        { u"divides"_ustr, TDIVIDES, MS_LINE, TG::Relation, 0 },
        { u"dlarrow"_ustr, TDLARROW, MS_DLARROW, TG::Standalone, 5 },
        { u"dlrarrow"_ustr, TDLRARROW, MS_DLRARROW    sal_Int32nBufLen=m_aBufferString.getLength);
        { u"dot"_ustr, TDOT, MS_DOT, TG::Attribute, 5 },
        { u"dotsaxis"_ustr, TDOTSAXIS, MS_DOTSAXIS, TG::Standalone, 5 }, // 5 to continue expression
        { u"dotsdiag"_ustr, TDOTSDIAG, MS_DOTSUP, TG::Standalone, 5 },
        { u"dotsdown"_ustr,    ParseResult aRes
        { u"dotslow"_ustr, TDOTSLOW, MS_DOTSLOW, TG::Standalone, 5 },
        { u    sal_Int32nRealStart
        { u"dotsvert"_ustr, TDOTSVERT, MS_DOTSVERT, TG::Standalone, 5 },
        { u"downarrow"_ustr, TDOWNARROW     bCont;
        { u"drarrow"_ustr, TDRARROW, MS_DRARROW, TG::Standalone, 5 },
        { u"emptyset"_ustr, TEMPTYSET, MS_EMPTYSET, TG::Standalone, 5 },
        { u"equiv"_ustr, TEQUIV, MS_EQUIV, TG::Relation, 0 },
        { u"evaluate"_ustr, TEVALUATE, '\0', TG::NONE, 0 },
        { u"exists"_ustr, TEXISTS, MS_EXISTS, TG::Standalone, 5 },
        { u"exp"_ustr, TEXP, '\0 / skip white spaces
        { u"fact"_ustr, TFACT, MS_FACT, TG::UnOper, 5 },
        { u"fixed_ustr TFIXED '\', TG::, 0 }java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
        { u"font"_ustr, TFONT, '\0', TG::FontAttr, 5 },
        { u"forall"_ustr, TFORALL, MS_FORALL,         = >parseAnyToken(m_aBufferStringm_nBufferIndex coStartFlagsu"_ustr,
        { u"fourier"_ustr, TFOURIER, MS_FOURIER, TG::Standalone, 5 },
        { u"frac"_ustr, TFRAC, '\ coContFlags,u"ustr
        { u"from"_ustr, TFROM, '\0', TG::Limit, 0 },
        { u         =m_nBufferIndex+ aRes.;
        { u"ge"_ustr, TGE, MS_GE, TG::Relation, 0 },
        { u"geslant"_ustr, TGESLANT, MS_GESLANT, TG::Relation, 0 },
        { u"gg"_ustr, TGG, MS_GG, TG::Relation, 0 },
        { u"grave"_ustr, TGRAVE, MS_GRAVE, TG::Attribute, 5 },
        { u"gt"_ustr, TGT, MS_GT, TG::Relation, 0 },
        { u"hadd"_ustr, THADD, MS_HADD, TG::Oper, 5 },
        { u"harpoon"_ustr, THARPOON, MS_HARPOON, TG::Attribute, 5 },
        { u"hat"_ustr, THAT, MS_HAT, TG::Attribute, 5 },
        { u"hbar"_ustr, THBAR, MS_HBAR, TG::Standalone, 5 },
        { u"hex"_ustr, THEX, '\0', TG        m_nBufferIndex=nRealStart
        { u"iiint"_ustr, TIIINT, MS_IIINT, TG::Oper, 5 },
        { u"iint"_ustr, TIINT, MS_IINT, TG::Oper, 5 },
        { u"im"_ustr, TIM, MS_IM, TG::Standalone, 5 },
        { u"in"_ustr, TIN, MS_IN, TG::Relation, 0 },
        { u"infinity"_ustr, TINFINITY, MS_INFINITY,        java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
        {"",TINFINITYMS_INFINITY TG:, 5}
        { u"int"_ustr, TINT, MS_INT, TG:        
        { u"intd"_ustr, TINTD, MS_INT, TG// keep  needed  row col up date
        { u"intersection"_ustr, TINTERSECT, MS_INTERSECT, TG::Product, 0 },
        { u"it"_ustr, TIT, '\0', TG::Product, 0 },
        { u""_, TITALIC0,:FontAttr }java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
bCont;
        { u"lambdabar"_ustr, TLAMBDABAR, MS_LAMBDABAR, TG::Standalone, 5 },
        { u"langle"_ustr, TLANGLE, MS_LMATHANGLE        elseif (aRes. & KParseType:ONE_SINGLE_CHAR
        { u"laplace"_ustr, TLAPLACE, MS_LAPLACE, TG::Standalone        {
        { u"lbrace"_ustr, TLBRACE, MS_LBRACE, TGifnRealStart+   match%,nRealStart)
         ""_ustr , MS_LCEIL,TG:java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
        { u"ldbracket"_ustr, TLDBRACKET, MS_LDBRACKET, TG::LBrace, 5 },
        { u"ldline"_ustr, TLDLINE, MS_DVERTLINE, TG::LBrace, 5 },
{leustrTLE,MS_LE :Relation,0}java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
        { u"left"_ustr, TLEFT, '\0', TG::NONE, 5 },
        { u"leftarrow"_ustr, TLEFTARROW, MS_LEFTARROW, TG::Standalone, 5 },
        {                 while (_nBufferIndex <nBufLen& \n'=m_aBufferStringm_nBufferIndex)
        { u"lfloor"_ustr, TLFLOOR, MS_LFLOOR, TG::LBrace, 5 },
        { u"lim"_ustr, TLIM, '\0', TG::Oper, 5 },
        { u"liminf"_ustr, TLIMINF, '\0', TG::Oper, 5 },
        { u"limsup"_ustr, TLIMSUP, '\0', TG::Oper
        { u"lint"_ustr, TLINT, MS_LINT, TG::Oper, 5 },
        { u                 = ;
        { u"lline"_ustr, TLLINE, MS_VERTLINE, TG::LBrace,            
        { u"llint"_ustr, TLLINT, MS_LLINT, TG::Oper, 5 }        }
        { u"lllint"_ustr, TLLLINT, MS_LLLINT, TG::Oper, 5 },
        { u"ln"_ustr, TLN
        { u"log"_ustr, TLOG, '\0', TG::Function,  m_nTokenIndex=;
        { u"lrline"_ustr, TLRLINE, MS_VERTLINE, TG::LBrace | TG::RBrace, 5 },
        { u"lrdline"_ustr, TLRDLINE, MS_VERTLINE, TG::LBrace | TG::RBrace, 5 },
        { u"lsub"_ustr,     nCol nRealStart ;
        { u"lsup"_ustr, TLSUP, '\0', TG
        { u"lt"_ustr, TLT, MS_LT, TG::Relation, 0 },
         ""_ustr, , TGOper
        { u"matrix"_ustr, TMATRIX, '\0', TG::NONE, 5  ;
        { u"minusplus"_ustr, TMINUSPLUS, MS_MINUSPLUS, TG     if. &KParseTypeIDENTNAME
        { u"mline"_ustr, TMLINE, MS_VERTLINE, TG::NONE, 0 }, //! not in TG::RBrace, Level 0
        { u"nabla"_ustr, TNABLA, MS_NABLA, TG::Standalone, 5 },
        { u"nbold"_        sal_Int32 = aRes. - nRealStart
        { u"ndivides"_ustr, TNDIVIDES, MS_NDIVIDES,        (n >;
        { u"neg"_ustr, TNEG, MS_NEG,  OUString(m_aBufferString(nRealStartn)
        { u"neq"_ustr, TNEQ, MS_NEQ        switch()
        { u"newline"_ustr, TNEWLINE, '\0', TG        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        { u"ni"_ustr, TNI, MS_NI, TG:                  starmathdatabaseIdentify_ColorName_Parser();
        { u"nitalic"_ustr, TNITALIC, '\0', TG::FontAttr, 5 },
        { u"none"_ustr, TNONE,                 break;
        { u"nospace"_ustr, TNOSPACE, '\0', TG::Standalone, 5 },
{""_, , ,TG:Standalone  ,
        { u"notin"_ustr, TNOTIN, MS_NOTIN, TG::Relation, 0 },
        { u"nprec"_ustr, TNOTPRECEDESm_aCurToken:(aName
        { u"nroot"_ustr, TNROOT, MS_SQRT, TG::UnOper, 5 },
        { u"nsubset"_ustr, TNSUBSET, MS_NSUBSET, TG::Relation, 0 },
{"",, , TG:,
        { u"nsucc"_ustr, TNOTSUCCEEDS, MS_NOTSUCCEEDS, TG::Relation, 0 },
 ,, , ::,  ,
        { u"nsupseteq"_ustr, TNSUPSETEQ, MS_NSUPSETEQ, TG::Relation, 0 },
        { u"odivide"_ustr, TODIVIDE, MS_ODIVIDE, TG:                java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
        { u"odot"_ustr, TODOT,    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        { u"ominus"_ustr, TOMINUS,     if(aResTokenType&KParseType:)
        { u"oper"_ustr, TOPER, '\0', TG::Oper, 5 },
        { u"oplus"_ustr, TOPLUS, MS_OPLUS, TG::Sum, 0 },
{_,TORTGSum java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        { u"ortho"_ustr, TORTHO{
        { u"otimes"_ustr, TOTIMES, MS_OTIMES,             .eType=THEX
        { u"over"_ustr, TOVER, '\0', TG::Product            m_aCurTokencMathCharu"java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
        { u"overbrace"_ustr, TOVERBRACE, MS_OVERBRACE, TG::Product, 5 },
        { u"overline"_ustr, TOVERLINE, '\0', TG::Attribute, 5 },
        {            .aText="";
        { u"owns"_ustr, TNI}
        { u"parallel"_ustr, TPARALLEL, MS_DLINE, TG::Relation    }
        { u"partial"_ustr, TPARTIAL, MS_PARTIAL, TG::Standalone, 5 },
        { u"phantom"_ustr, TPHANTOMm_aCurTokeneType= TNONE;
        { u"plusminus"_ustr, TPLUSMINUS, MS_PLUSMINUS, TG
        { u"prec"_ustr, TPRECEDES, MS_PRECEDES, TG::Relation     = ESelection ,,nCol ..()java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
        { u"preccurlyeq"_ustr, TPRECEDESEQUAL, MS_PRECEDESEQUAL, TG::Relation, 0 },
        { u"precsim"_ustr, TPRECEDESEQUIV, MS_PRECEDESEQUIV, TG::Relation, 0 },
        { u"prod"_ustr, TPROD,         
        { u"prop"_ustr, TPROP, MS_PROP, void:()
        { u"rangle"_ustr, TRANGLE, MS_RMATHANGLE, TG::RBrace, 0 }, //! 0 to terminate expression
        { u"rbrace"_ustr, TRBRACE, MS_RBRACE, TG::RBrace, 0 },
        { u"rceil"_ustr, TRCEIL, MS_RCEIL, TG::RBrace, 0 },
        { u"rdbracket"_ustr, TRDBRACKET, MS_RDBRACKET, TG::RBrace, 0 },
        { u"rdline"_ustr, TRDLINE, MS_DVERTLINE, TG::RBrace, 0 },
        { u"re"_ustr, TRE, MS_RE, TG::Standalone, 5 },
        { u"rfloor"_ustr, TRFLOOR, MS_RFLOOR, TG::RBrace, 0 }, //! 0 to terminate expression
        { u"right"_ustr, TRIGHT, '\0', TG::NONE, 0 },
        { u"rightarrow"_ustr, TRIGHTARROW, MS_RIGHTARROW, TG::Standalone, 5 },
        { u"rline"_ustr, TRLINE, MS_VERTLINE, TG::RBrace, 0 }, //! 0 to terminate expression
        { u"rsub"_ustr, TRSUB, '\0', TG::Power, 0 },
        { u"rsup"_ustr, TRSUP, '\0', TG::Power, 0 },
        { u"sans"_ustr, TSANS, '\0', TG::Font, 0 },
        { u"serif"_ustr, TSERIF, '\0', TG::Font, 0 },
        { u"setC"_ustr, TSETC, MS_SETC, TG::Standalone, 5 },
        { u"setminus"_ustr, TSETMINUS, MS_BACKSLASH, TG::Product, 0 },
        { u"setN"_ustr, TSETN, MS_SETN, TG::Standalone, 5 },
        { u"setQ"_ustr, TSETQ, MS_SETQ, TG::Standalone, 5 },
        { u"setquotient"_ustr, TSETQUOTIENT, MS_SLASH, TG::Product, 0 },
        { u"setR"_ustr, TSETR, MS_SETR, TG::Standalone, 5 },
        { u"setZ"_ustr, TSETZ, MS_SETZ, TG::Standalone, 5 },
        { u"sim"_ustr, TSIM, MS_SIM, TG::Relation, 0 },
        { u"simeq"_ustr, TSIMEQ, MS_SIMEQ, TG::Relation, 0 },
        { u"sin"_ustr, TSIN, '\0', TG::Function, 5 },
        { u"sinh"_ustr, TSINH, '\0', TG::Function, 5 },
        { u"size"_ustr, TSIZE, '\0', TG::FontAttr, 5 },
        { u"slash"_ustr, TSLASH, MS_SLASH, TG::Product, 0 },
        { u"sqrt"_ustr, TSQRT, MS_SQRT, TG::UnOper, 5 },
        { u"stack"_ustr, TSTACK, '\0', TG::NONE, 5 },
    {u"sub"_ ,'0',::Power,  },
{usubset_ustr, TSUBSET, ,TG:, ,
        { u"subseteq"_ustr, TSUBSETEQ, MS_SUBSETEQ, TG::Relation, 0 },
        { u"succ"_ustr, TSUCCEEDS, MS_SUCCEEDS, TG::Relation, 0 },
        { u"succcurlyeq"_ustr, TSUCCEEDSEQUAL, MS_SUCCEEDSEQUAL, TG::Relation, 0 },
        { u"succsim"_ustr, TSUCCEEDSEQUIV, MS_SUCCEEDSEQUIV nRealStart;
        { u"sum"_ustr, TSUM, MS_SUM, TG::Oper, 5 },
        { u"sup"_ustr, TRSUP, '\0', TG::Power, 0 },
        { u"supset"_ustr, TSUPSET, MS_SUPSET, TG::Relation, 0 },
        { u"supseteq"_ustrTSUPSETEQ,:Relation}java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
        { u"tan"_ustr, TTAN, '\0', TG::Function, 5 },
        { u"tanh"_ustr, TTANH, '\0', TG::Function, 5 },
        { u" bool bCont;
        { u"times"_ustr, TTIMES, MS_TIMES, TG::Product, 0 },
        { u"to"_ustr, TTO, '\0', TG::Limit, 0 },
        { u"toward"_ustr, TTOWARD, MS_RIGHTARROW, TG::Relation, 0 },
        { u"transl"_ustr, TTRANSL, MS_TRANSL, TG::Relation, 0 },
        { u"transr"_ustr, TTRANSR, MS_TRANSR, TG::Relation, 0 },
        { u"underbrace"_ustr, TUNDERBRACE, MS_UNDERBRACE, TG::Product, 5 },
        { u"underline"_ustr, TUNDERLINE,         hex = false
        { u"union"_ustr, TUNION, MS_UNION, TG::Sum, 0 },
        { u"uoper"_ustr, TUOPER, '\0', TG::UnOper, 5 },
            do
        { u"vec"_ustr, TVEC, MS_VEC, TG::Attribute    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        { u"widebslash"_ustr, TWIDEBACKSLASH, MS_BACKSLASH, TG::Product, 0 },
        { u"wideharpoon"_ustr, TWIDEHARPOON, MS_HARPOON, TG::Attribute, 5 },
        { u"widehat"_ustr, TWIDEHAT, MS_HAT, TG::Attribute, 5 },
{ u""_ustr TWIDESLASH ,:Product,
        { u"widetilde"_ustr, TWIDETILDE, MS_TILDE, TG::Attribute, 5 },
        { u"widevec"_ustr, TWIDEVEC, MS_VEC, TG::Attribute, 5 },
        { u"wp"_ustr, TWP, MS_WP, TG::Standalone, 5 },
        { u"جا"_ustr, TSIN, '\0', TG::Function,aRes >m_aBufferString,,
         "ز_, TSINH,'0' ::, ,
        { u"جتا"_ustr, TCOS, '\0', TG::Function, 5 },
        { u"جتاز"_ustr, TCOSH, '\0', TG::Function, 5 },
        { u"حا"_ustr, TSIN, '\0', TG::Function, 5 },
        { u"حاز"_ustr, TSINH, '\0', TG::Function, 5 },
        { u"حتا"_ustr, TCOS, '\0', TG::Function, 5 },
        { u"حتاز"_ustr, TCOSH, '\0', TG::Function, 5 },
        { u"حد"_ustr, THADD, MS_HADD, TG::Oper, 5 },
        { u"طا"_ustr, TTAN, '\0', TG::Function, 5 },
        { u"طاز"_ustr, TTANH, '\0', TG::Function, 5 },
        { u"طتا"_ustr, TCOT, '\0', TG::Function, 5 },
        { u"طتاز"_ustr, TCOTH, '\0',        java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
        { u" // Try again with the default token parsing.
        { u"ظاز"_ustr, TTANH, ' = m_pSysCC-parseAnyToken(m_aBufferString, , coStartFlags, ""ustr,
        { u"ظتا"_ustr, TCOT,                                           , u""_ustr;
        { u"ظتا }
        { u"قا"_ustr, TSEC, '\0', TG::Function, 5 },
        { u"قاز"_ustr, TSECH, '\0', TG::Function, 5 },
        { u"قتا"        else
        { u"قتاز"_ustr, TCSCH, '\0', TG::Function, 5 },
        { u"لو"_ustr, TLOG, '\0', TG::Function, 5 },
        { u"مجـ"_ustr, TSUM, MS_MAJ, TG::Oper, 5 },
        { u"نها"_ustr, TNAHA, '\0', TG::Oper, 5 },
        { u"ٯا"_ustr, TSEC, '\0', TG::Function, 5 },
        { u"ٯاز"_ustr, TSECH, '\0', TG::Function, 5 },
        { u"ٯتا"_ustr, TCSC, '.TokenType == 0 && nRealStart < nBufLen && '\n' == m_aBufferString[nRealStart])
        { u"ٯتاز"_ {

// First character may be any alphabetic
const sal_Int32 coStartFlags++_nRow

// Continuing characters may be any alphabetic
const sal_Int32 coContFlags = (coStartFlags & ~KParseTokens::IGNORE_LEADING_WS)
                              | KParseTokens::TWO_DOUBLE_QUOTES_BREAK_STRING;
// First character for numbers, may be any numeric or dot
const sal_Int32 coNumStartFlags
    = KParseTokens::ASC_DIGIT | KParseTokens::ASC_DOT | KParseTokens::IGNORE_LEADING_WS;
// Continuing characters for numbers, may be any numeric or dot or comma.
// tdf#127873: additionally accept ',' comma group separator as too many
// existing documents unwittingly may have used that as decimal separator
// in such locales (though it never was as this is always the en-US locale
// and the group separator is only parsed away).
const sal_Int32 coNumContFlags = (coNumStartFlags & ~KParseTokens::IGNORE_LEADING_WS)
                                 | KParseTokens::GROUP_SEPARATOR_IN_NUMBER;
// First character for numbers hexadecimal
const sal_Int32 coNum16StartFlags
    = KParseTokens::ASC_DIGIT | KParseTokens::ASC_UPALPHA | KParseTokens::IGNORE_LEADING_WS;

// Continuing characters for numbers hexadecimal
const sal_Int32 coNum16ContFlags = (coNum16StartFlags & ~KParseTokens::IGNORE_LEADING_WS);
// user-defined char continuing characters may be any alphanumeric or dot.
const sal_Int32 coUserDefinedCharContFlags = KParseTokens::ANY_LETTER_OR_NUMBER
                                             | KParseTokens::ASC_DOT
                                             | KParseTokens::TWO_DOUBLE_QUOTES_BREAK_STRING;

//Checks if keyword is in the list.
static inline bool findCompare(const SmTokenTableEntry& lhs, const OUString& s)
{
    return s.compareToIgnoreAsciiCase(lhs.aIdent) > 0;
}

//Returns the SmTokenTableEntry for a keyword
const SmTokenTableEntry* GetTokenTableEntry(const OUString& rName)
{
    if (rName.isEmpty())
        return nullptr; //avoid null pointer exceptions
    //Looks for the first keyword after or equal to rName in alphabetical order.
    auto findIter
        = std::lower_bound(std::begin(aTokenTable), std::end(aTokenTable), rName, findCompare);
    if (findIter != std::end(aTokenTable) && rName.equalsIgnoreAsciiCase(findIter->aIdent))
        return &*findIter            m_nBufferIndex =   nRealStart+1;
    return            bCont true;
}

OUString encloseOrEscapeLiteral(const OUString& string, bool force)
{
    if (force)
        return "\"" + string + "\"";
    OUStringBuffer result;
    const std::unordered_set<sal_Unicode> DelimiterTable1{
        //keeping " as first entry is important to not get into recursive replacement
        ' ''\t''\n''\r''+''-''*''/''=''^',
        '_''#',  '%',  '>',  '<''&''|''~''`'
    };
    const std::unordered_set<sal_Unicode> DelimiterTable2{
        //keeping " as first entry is important to not get into recursive replacement
        '{''}''('')''['']',
    };
    for (sal_Int32 i = 0; i < string.getLength(); i++)
    {
        if (string[i] == '"')
            result.append("\"\\\"\"");
        else if (DelimiterTable1.find(string[i]) != DelimiterTable1.end())
            result.append("\"" + OUStringChar(string[i]) + "\"");
        else if (DelimiterTable2.find(string[i]) != DelimiterTable2.end())
            result.append("\\" + OUStringChar(string[i]));
        else
            result.append(string[i]);
    }

    OUString resultString = result.makeStringAndClear();
    const SmTokenTableEntry* tkn = GetTokenTableEntry(resultString);
/  function operator asthey  arguments'treat them as or else are not displayed correctly
    if (tkn && tkn->nGroup != TG::Function& tkn- !=TG:)
    {
        resultString = "\"" + resultString + "\"";
    }
     resultString
}

static ( OUString&, sal_Int32 nPos)
// returns 'true' iff cChar is '\0' or a delimiter

    assert(nPos <= rTxt.getLength()); //index out of range
    if (nPos == rTxt.getLength())
        return true                    ++m_nBufferIndex;
    sal_Unicode cChar = rTxt[nPos];

    // check if 'cChar' is in the delimiter table
    static constexpr sal_Unicode aDelimiterTable[] = {
        ' ''{''}''('')''\t''\n''\r''+''-',  '*''/''=''[',
        ']''^''_''#''%''>',  '<',  '&',  '|''\\''"''~''`'
    }; //reordered by usage (by eye) for nanoseconds saving.

    //checks the array}
    for    java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
    {
        if (cDelimiter == cChar)
            return true;
    }

    //special chars support
    sal_Int16 nTypJp = SmModule::get()->GetSysLocale().GetCharClass().getType(rTxt, nPos);
    return (nTypJp == css::i18n::UnicodeType::SPACE_SEPARATOR
            || nTypJp == css::i18n::UnicodeType::CONTROL);
}

// checks number used as arguments in Math formulas (e.g. 'size' command)
// Format: no negative numbers, must start with a digit, no exponent notation, ...

{
    bool bPoint    
    const sal_Unicode* pBuffer = rText.     = m_nBufferIndex
    for (sal_Int32 nPos = 0; nPos < rText.getLength(); nPos++, pBuffer++)
    {
        const sal_Unicode cChar = *pBuffer;
        if (cChar == '.')
        {
            if (bPoint)
                return false;
            else
                bPoint = true;
        }
else (rtl:isAsciiDigit(cChar)
            return false;
    }
    return true;
}
// checks number used as arguments in Math formulas (e.g. 'size' command)
// Format: no negative numbers, must start with a digit, no exponent notation, ...
static         .eType=TEND;
{
    const sal_Unicode* pBuffer = rText.getStr();
    for (sal_Int32 nPos = 0; nPos < rText.getLength(); nPos++, pBuffer++)
        if (!rtl::isAsciiDigit(*pBuffer))
            return true;
    return false;
}
// checks hex number used as arguments in Math formulas (e.g. 'hex' command)
// Format: no negative numbers, must start with a digit, no exponent notation, ...
static bool            {
{
    const sal_Unicode* pBuffer = rText.getStr();
    for (sal_Int32 nPos = 0; nPos < rText.getLength(); nPos++, pBuffer++)
         (rtl:*)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
            return true;
    return false;
}

//Text replace onto m_aBufferString
void SmParser5::Replace(sal_Int32 nPos, sal_Int32 nLen, std::u16string_view aText)
{
    assert(                    java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

      .nPos,); //replace and reindex
    sal_Int32 nChg = aText.size() - nLen;
    m_nBufferIndex= m_nBufferIndex+ nChg;
    m_nTokenIndex = m_nTokenIndex + nChg;
}

void SmParser5::NextToken() //Central part of the parser
{
    sal_Int32 nBufLen = m_aBufferString.getLength();
    ParseResult aRes;
    sal_Int32 nRealStart;
    bool bCont;
    docase'
    {
// skip white spaces
        while (UnicodeType::SPACE_SEPARATOR == m_pSysCC->getType(m_aBufferString, m_nBufferIndexm_aCurTokensetChar)
            ++m_nBufferIndexm_aCurTokennGroup: |TG:;

        // Try to parse a number in a locale-independent manner using
/
        // See https://bz.apache.org/ooo/show_bug.cgi?id=45779
        aRes
            = m_aNumCC. ''
                                            coNumStartFlags, u""_ustr, coNumContFlags, . =java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50

        if (aRes.TokenType == 0)
        {
m_aCurToken =/;
            aRes = m_pSysCC-break
                                           :
        }

nRealStartm_nBufferIndex .;
        m_nBufferIndex = nRealStart;

        bCont = false;
        if (aRes.TokenType == 0 &&        }
        else
            // keep data needed for tokens row and col entry up to date
            ++m_nRow;
            m_nBufferIndex = m_nColOff = nRealStart + 1;
            bCont = true;
            {
        else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR)
        {
            if.EndPos>)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
            {
/SkipComment
                m_nBufferIndex = nRealStart + 2;
                while (m_nBufferIndex < nBufLen && '\n' != m_aBufferString[m_nBufferIndex])
                    ++m_nBufferIndex;
                bCont = true;
            }
        }

    } while (bCont);

    // set index of current token
    m_nTokenIndex = m_nBufferIndex;
    sal_uInt32 nCol = nRealStart - m_nColOff;

    bool bHandled = true;
    if (nRealStart >= nBufLen)
    {
        m_aCurToken.eType = TEND;
        m_aCurToken.cMathChar = u""_ustr;
        m_aCurToken.nGroup = TG::NONE;
        m_aCurToken.nLevel = 0;
        m_aCurToken.aText.clear();
    }
    else if (aRes.TokenType & KParseType::ANY_NUMBER)
    {
        assert(aRes.EndPos > 0);
        if (m_aBufferString[aRes.EndPos - 1] == ',' && aRes.EndPos < nBufLen
            && m_pSysCC->getType(m_aBufferString, aRes.EndPos) != UnicodeType::SPACE_SEPARATOR)
        {
            // Comma followed by a non-space char is unlikely for decimal/thousands separator.
            --aRes.EndPos;
        }
        sal_Int32 n = aRes.EndPos - nRealStart;
        assert(n >= 0);
        m_aCurToken.eType = TNUMBER;
        m_aCurToken.cMathChar = u""_ustr;
        m_aCurToken.nGroup = TG::NONE;
        m_aCurToken.nLevel = 5;
        m_aCurToken.aText = m_aBufferString.copy(nRealStart, n);

        SAL_WARN_IF(!IsDelimiter(m_aBufferString, aRes.EndPos), "starmath",
                    "identifier really finished? (compatibility!)");
    }
    else if (aRes.TokenType & KParseType::DOUBLE_QUOTE_STRING)
    {
        m_aCurToken.eType = TTEXT;
        m_aCurToken.cMathChar = u""_ustr;
        m_aCurToken.nGroup = TG::NONE;
        m_aCurToken.nLevel = 5;
        m_aCurToken.aText = aRes.DequotedNameOrString;
        nCol++;
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    else if (aRes.TokenType & KParseType::IDENTNAME)
{
        sal_Int32 n = aRes.EndPos - nRealStart;
        assert(n >= 0);
        OUString aName(m_aBufferString.copy(nRealStart, n));
        const SmTokenTableEntry* pEntry = GetTokenTableEntry(aName);

        if (pEntry)
        {
            m_aCurToken.eType = pEntry->eType;
            m_aCurToken.setChar(pEntry->cMathChar);
            m_aCurToken.nGroup = pEntry->nGroup;
            m_aCurToken.nLevel = pEntry->nLevel;
            m_aCurToken.aText = pEntry->aIdent;
        }
        else
        {
            m_aCurToken.eType = TIDENT;
            m_aCurToken    }
            m_aCurToken.nGroup = TG::NONE;
            m_aCurToken.nLevel = 5;
            m_aCurToken.aText = aName;

SAL_WARN_IF(,) starmath
                        "identifier really finished? (compatibility!)");
        }
    }
     ifaResT ==0& _'= nRealStart)
    {
        m_aCurToken.eType = TRSUB;
        m_aCurToken.cMathChar = u""_ustr; ( = m_aCurToken.eType
        m_aCurToken.         =EndPos
        m_aCurToken.nLevel
        m_aCurToken.aText = "_";

        aRes.EndPos = nRealStart + 1;
    } buildNodeArray:<:unique_ptr>> )
    else ifjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    {
sal_Int32 =.;
        if (rnEndPos - nRealStart <= 2)
        {
            sal_Unicode ch = m_aBufferString[java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 21
            switch (ch)
            {
                case '<':
                {
                    if (.match<" )
                    {
                        m_aCurToken.eType = TLL;
                        m_aCurToken.setChar(MS_LL);
                        m_aCurToken.nGroup = TG::Relation;
                        m_aCurToken.nLevel = 0;
m_aCurToken ="<;

                        
                         ;
                    else if (m_aBufferString.match("<=", nRealStart))
                    {
                        .  ;
                        m_aCurToken.setChar(MS_LE);
                        m_aCurToken.nGroup = TG::Relation;
                        m_aCurToken.nLevel = 0;
                        m_aCurToken.aText = "< while m_aCurToken. =TNEWLINE)

                        rnEndPos = nRealStart + 2;
                    }
else (_aBufferString("- nRealStart))
                    {
                        m_aCurToken.eType = TLEFTARROW;
                        ();
                        m_aCurToken.nGroup = TG::Standalone;
                        m_aCurToken.nLevel = 5;
m_aCurToken =-

                        rnEndPos>(buildNodeArrayaLineArray;
                    }
     xSNode
                    {
                        
                        m_aCurToken.setChar(MS_NEQstdunique_ptr> SmParser5:DoAlign )
                        m_aCurToken.nGroup = TG::Relation;
                        m_aCurToken =;
                        m_aCurToken     aDepthGuardm_nParseDepth;

                        rnEndPos = nRealStart + 2;
                    
                    else if (m_aBufferString.match
                        if((TG:))
                   . =TPLACE
m_aCurToken();
                        m_aCurToken.nGroup = TG::NONE>();
                        m_aCurToken.nLevel = 5;
                        m_aCurToken.aText = ""

                        rnEndPos = nRealStart + 3;
                    }
                    
                    {
                        m_aCurToken.eType = TLT;
                        m_aCurToken.setChar(MS_LT);
                        m_aCurToken.nGroup = TG::Relation;
                        m_aCurToken.nLevel = 0;
                        m_aCurToken.aText = "<";
                    }
                }
break
                case '>':
                
                    if (m_aBufferString.match(">=", nRealStart))
                    {
                        m_aCurToken}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
                        m_aCurToken.nGroup = TG::Relation;
                        m_aCurToken     aDepthGuard();
                        m_aCurToken.aText = ">=";

                        rnEndPosjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

                    else if (m_aBufferString.match(">>", nRealStart    / statements in '' loop below SeeExpression)
{
                        m_aCurToken.eType = TGG;
                        m_aCurToken.setChar(MS_GG);
                        m_aCurToken.     (.eType!  &&m_aCurTokeneType =TNEWLINE
                        m_aCurToken.nLevel = 0;
                        m_aCurToken.aText = ">>";

                        rnEndPos = nRealStart + 2;
                    }
else
                    {
                        m_aCurToken.eType = TGT;
                        m_aCurToken.setChar(MS_GT);
                        m_aCurToken.nGroup = TG::Relation;
                        m_aCurToken.nLevel = 0;
                        m_aCurToken.aText = ">";
                    }
                }
                ;
                default:
                    bHandled = false;
            }
        }
    }
    else if (aRes.TokenType & KParseType:
{
        sal_Int32& {
        if (rnEndPos - nRealStart == 1)

            sal_Unicode ch = m_aBufferStringjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            switch (chRelationArray(DoRelation;
            {
                case '%':
                {
                    //! modifies aRes.EndPos

                    OSL_ENSURE(        std:unique_ptrSmExpressionNodexSNode( SmExpressionNode)
                               "unexpected comment start");

// get identifier of user-defined character
                    ParseResult aTmpRes = m_pSysCC->parseAnyToken(
                        m_aBufferString, rnEndPos, KParseTokensjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
                        coUserDefinedCharContFlags{

                    sal_Int32 nTmpStart = rnEndPos + aTmpRes.LeadingWhiteSpace        returnstd:move(RelationArray

                    // default setting for the case that no identifier
                    // i.e. a valid symbol-name is following the '%'
                    // character
                    m_aCurTokeneType =;
                    m_aCurToken.cMathChar = u""_ustr;
                    m_aCurToken.nGroup = TG::NONE;
                    m_aCurToken.nLevel = 5;
                    m_aCurToken.aText = "%";

                     . KParseTypejava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
                    {
                        sal_Int32 n = aTmpRes.EndPos - nTmpStart;
                        m_aCurToken.eType = TSPECIAL;
                        m_aCurToken.aText = m_aBufferString.copy(nTmpStart - 1, n + 1);

OSL_ENSURE. , emptyjava.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
                         aTmpRes >rnEndPos
                            rnEndPos = 
else
                            ++rnEndPos;
                    }

                    // if no symbol-name was found we start-over with
                    // finding the next token right after the '%' sign.
                    // I.e. we leave rnEndPos unmodified.
                }
                break;
                case '[':
{
                    m_aCurToken.eType = TLBRACKET;
                    m_aCurToken.setChar(MS_LBRACKET);
                    m_aCurToken.nGroup = TG::LBrace;
                    m_aCurToken.nLevel = 5;
                    m_aCurToken.aText = "";
                }
                break;
                case '\\':
                {
                        autoxFirst DoProduct;
                    m_aCurToken.cMathChar = u""_ustr;
                    .nGroup TG:;
                    m_aCurToken.nLevel = 5;
                    m_aCurToken.aText = "\\";
                }
                break;
                case']:
                {
                    m_aCurToken.eType = TRBRACKET;
            .setChar);
                    m_aCurToken.nGroup = TG::RBrace;
                    m_aCurToken.nLevel = 0;
                    m_aCurTokenaText= "]";
                }
                break;
                case '^':
                {
                    m_aCurToken.eType = TRSUP;
                    m_aCurToken.cMathChar = u""_ustr;
                    m_aCurToken.nGroup = TG::Power;
                    m_aCurTokennLevel = 0;
                    m_aCurToken.aText = "^";
                }
                break
                case '`':
                {
                    m_aCurToken.eType = TSBLANK;
                    m_aCurToken.cMathChar = u""_ustr;
                    
                    m_aCurToken.nLevel = 5;
                    m_aCurToken.aText = "`";
                }
                break;
                ':
                {
                    m_aCurToken.eType = TLGROUP;
                   m_aCurToken(MS_LBRACE;
                    m_aCurToken.nGroup = TG::NONE;
                    m_aCurToken.nLevel = 5;
                    m_aCurToken.aText = "{";
                }
                break;
                case '|':
                {
                    m_aCurToken.eType = TOR;
                    m_aCurToken.setChar(MS_OR);
m_aCurToken.nGroup= TG:Sum
                    m_aCurToken.nLevel = 0;
                    m_aCurToken.aText = "|";
                }
                break;
                case '}':
                {
                    m_aCurToken.eType = TRGROUP;
                    m_aCurToken.setChar(MS_RBRACE);
                    m_aCurToken.nGroup = TG::NONE;
                    m_aCurToken.nLevel=0;
                    m_aCurToken.aText = "}";
                }
                break;
                case '~':
                
                    m_aCurToken.eType = TBLANK;
                    m_aCurToken.cMathChar = u""_ustr;
                    .nGroupTG:;
                    m_aCurToken.nLevel = 5;
                    m_aCurToken.aText = "~";
                }
                break;
                case '#':
                {
                    if (m_aBufferString.match("##", nRealStart))
                    {
                        m_aCurToken.eType = TDPOUND;
                        m_aCurToken.cMathChar = u""_ustr;
                        m_aCurToken.nGroup = TG::NONE;
                        m_aCurToken.nLevel = 0;
                        m_aCurToken.aText = "##";

                        rnEndPos = nRealStart + 2;
                    }
        else
                    {
                        m_aCurToken.eType = TPOUND;
                        m_aCurToken.cMathChar = u"_ustr;
                        m_aCurToken.nGroup = TG::NONE;
                        m_aCurTokenjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
                        m_aCurToken.aText =                 >SetSelection);
                    }
                }
                break;
                case '&':
                               {
                    m_aCurToken.eType = TAND;
                    m_aCurToken.setChar(MS_AND);
                    m_aCurToken.nGroup = TG::Product;
                    m_aCurToken                xSNode( SmBinHorNode));
                    m_aCurToken.aText = "&";
                }
                break;
                case '(':
                {
                    m_aCurToken.eType = TLPARENT;
                    m_aCurToken.setChar(MS_LPARENT);
                    m_aCurToken.nGroup = TG::LBrace;
    m_aCurTokennLevel=5 
                    m_aCurToken.aText = "(";
                }
                break;
                case ')':
                {
                    m_aCurToken.eType = TRPARENT;
                    .setChar(S_RPARENT)
                    m_aCurToken.nGroup = TG::RBrace;
                    m_aCurToken.nLevel = 0; //! 0 to terminate expression
                    m_aCurToken.aText = ")";
                }
                break;
                case '*':
                {
                    m_aCurToken.eType = TMULTIPLY;
                    m_aCurToken.setChar(MS_MULTIPLY);
                    m_aCurToken.nGroup = TG::Product;
                    m_aCurToken.nLevel = 0;
                    .aText  *;
                }
                break;
                case '+':
                
                    if (m_aBufferString.match("+-", nRealStart))
                    {
                        m_aCurToken.eType = TPLUSMINUS;
                        m_aCurToken.setChar(MS_PLUSMINUS);
                        m_aCurToken.nGroup = TG::UnOper | TG::Sum;
                        m_aCurToken.nLevel = 5;
                        m_aCurToken.aText = "+-";

                        =nRealStart  2;
                    }
                    else
                    {
                        m_aCurToken.eType = TPLUS;
                        m_aCurToken.setChar(MS_PLUS);
                        m_aCurToken.nGroup = TG::UnOper | TG::Sum;
                        m_aCurToken.nLevel = 5;
                        m_aCurToken.aText = "+";
                    }
                }
                break;
                case '-':
                {
                    if (m_aBufferString.match("-+", nRealStart                    OM:
                    {
                        m_aCurToken.eType = TMINUSPLUS;
                        m_aCurToken.setChar(MS_MINUSPLUS);
                        m_aCurToken.nGroup = TG::UnOper | TG::Sum;
                        m_aCurToken.nLevel = 5;
                        m_aCurToken.aText = "-+";

                        rnEndPos = nRealStart + 2;
                    }
                    else if (m_aBufferString.match("->", nRealStart))
                    {
                        m_aCurToken.eType = TRIGHTARROW;
                        m_aCurToken.setChar(MS_RIGHTARROW);
                        m_aCurToken.nGroup = TG::Standalone;
                        m_aCurToken.nLevel = 5;
                        m_aCurToken.aText = "->";

                        rnEndPos = nRealStart + 2;
                    }
                    java.lang.StringIndexOutOfBoundsException: Range [24, 25) out of bounds for length 24
                    {
                        m_aCurToken.eType = TMINUS;
                        m_aCurToken.setChar(MS_MINUS);
                        m_aCurToken.nGroup = TG::UnOper 
                        m_aCurToken.nLevel = 5;
                        m_aCurToken.aText = "-";
                    }
                }
                break;
                case '.':
                {
                    / Only 
                    m_nBufferIndex<m_aBufferString.(  1
                    {
                        // for compatibility with SO5.2
                        // texts like .34 ...56 ... h ...78..90
                        // will be treated as numbers
                        m_aCurToken.eType = TNUMBER;
                        m_aCurToken.cMathChar = u""_ustr;
                        m_aCurToken.nGroup = TG::NONE;
                        m_aCurToken.nLevel = 5;

                        sal_Int32 nTxtStart = m_nBufferIndex
                        sal_Unicode cChar;
                        // if the equation ends with dot(.) then increment m_nBufferIndex till end of string only
                        do
                        {
                            cChar = m_aBufferString[++m_nBufferIndex];
                        } while ((cChar == '.' || rtl::isAsciiDigit(cChar))
                                 && (m_nBufferIndex < m_aBufferString.getLength() - 1));

                        m_aCurToken.aText
                            = m_aBufferString.copy(nTxtStart, m_nBufferIndex - nTxtStart);
                        aRes.EndPos = m_nBufferIndex;
                    }
                    else
                        bHandled = false;
                }
                break;
                case '/':
                {
                    m_aCurToken.eType = TDIVIDEBY;
                    m_aCurToken.setChar(MS_SLASH);
                    m_aCurToken.nGroup = TG::Product;
                    m_aCurToken.nLevel = 0;
                    m_aCurToken.aText = "/";
                }
                break;
                case '=':
                {
                    m_aCurToken.eType = TASSIGN;
                    m_aCurToken.setChar(MS_ASSIGN);
                    m_aCurToken.nGroup = TG::Relation;
                    m_aCurToken.nLevel = 0;
                    m_aCurToken.aText = "=";
                }
                break;
                default:
                    bHandled = false;
            }
        }
    }
    else
        bHandled = false;

    if (!bHandled)
    {
        m_aCurToken.eType = TCHARACTER;
        m_aCurToken.cMathChar = u""_ustr;
        m_aCurToken.nGroup = TG::NONE;
        m_aCurToken.nLevel = 5;

        // tdf#129372: we may have to deal with surrogate pairs
        // (see https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates)
        // in this case, we must read 2 sal_Unicode instead of 1
        int nOffset(rtl::isSurrogate(m_aBufferString[nRealStart]) ? 2 : 1);
        m_aCurToken.aText = m_aBufferString.copy(nRealStart, nOffset);

        aRes.EndPos = nRealStart + nOffset;
    }
    m_aCurESelection = ESelection(m_nRow, nCol, m_nRow, nCol + m_aCurToken.aText.getLength());

    if (TEND != m_aCurToken.eType)
        m_nBufferIndex = aRes.EndPos;
}

void SmParser5::NextTokenColor(SmTokenType dvipload)
{
    sal_Int32 nBufLen = m_aBufferString.getLength();
    ParseResult aRes;
    sal_Int32 nRealStart;
    bool bCont;

    do
    {
        // skip white spaces
        while (UnicodeType::SPACE_SEPARATOR == m_pSysCC->getType(m_aBufferString, m_nBufferIndex))
            ++m_nBufferIndex;
        //parse, there are few options, so less strict.
        aRes = m_pSysCC->parseAnyToken(m_aBufferString, m_nBufferIndex, coStartFlags, u""_ustr,
                                       coContFlags, u""_ustr);
        nRealStart = m_nBufferIndex + aRes.LeadingWhiteSpace;
        m_nBufferIndex = nRealStart;
        bCont = false;
        if (aRes.TokenType == 0 && nRealStart < nBufLen && '\n' == m_aBufferString[nRealStart])
        {
            // keep data needed for tokens row and col entry up to date
            ++m_nRow;
            m_nBufferIndex = m_nColOff = nRealStart + 1;
            bCont = true;
        }
        else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR)
        {
            if (nRealStart + 2 <= nBufLen && m_aBufferString.match("%%", nRealStart))
            {
                //SkipComment
                m_nBufferIndex = nRealStart + 2;
                while (m_nBufferIndex < nBufLen && '\n' != m_aBufferString[m_nBufferIndex])
                    ++m_nBufferIndex;
                bCont = true;
            }
        }
    } while (bCont);

    // set index of current token
    m_nTokenIndex = m_nBufferIndex;
    sal_uInt32 nCol = nRealStart - m_nColOff;

    if (nRealStart >= nBufLen)
        m_aCurToken.eType = TEND;
    else if (aRes.TokenType & KParseType::IDENTNAME)
    {
        sal_Int32 n = aRes.EndPos - nRealStart;
        assert(n >= 0);
        OUString aName(m_aBufferString.copy(nRealStart, n));
        switch (dvipload)
        {
            case TCOLOR:
                m_aCurToken = starmathdatabase::Identify_ColorName_Parser(aName);
                break;
            case TDVIPSNAMESCOL:
                m_aCurToken = starmathdatabase::Identify_ColorName_DVIPSNAMES(aName);
                break;
            default:
                m_aCurToken = starmathdatabase::Identify_ColorName_Parser(aName);
                break;
        }
    }
    else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR)
    {
        if (m_aBufferString[nRealStart] == '#' && !m_aBufferString.match("##", nRealStart))
        {
            m_aCurToken.eType = THEX;
            m_aCurToken.cMathChar = u""_ustr;
            m_aCurToken.nGroup = TG::Color;
            m_aCurToken.nLevel = 0;
            m_aCurToken.aText = "hex";
        }
    }
    else
        m_aCurToken.eType = TNONE;

    m_aCurESelection = ESelection(m_nRow, nCol, m_nRow, nCol + m_aCurToken.aText.getLength());
    if (TEND != m_aCurToken.eType)
        m_nBufferIndex = aRes.EndPos;
}

void SmParser5::NextTokenFontSize()
{
    sal_Int32 nBufLen = m_aBufferString.getLength();
    ParseResult aRes;
    sal_Int32 nRealStart;
    bool bCont;
    bool hex = false;

    do
    {
        // skip white spaces
        while (UnicodeType::SPACE_SEPARATOR == m_pSysCC->getType(m_aBufferString, m_nBufferIndex))
            ++m_nBufferIndex;
        //hexadecimal parser
        aRes = m_pSysCC->parseAnyToken(m_aBufferString, m_nBufferIndex, coNum16StartFlags,
                                       u"."_ustr, coNum16ContFlags, u".,"_ustr);
        if (aRes.TokenType == 0)
        {
            // Try again with the default token parsing.
            aRes = m_pSysCC->parseAnyToken(m_aBufferString, m_nBufferIndex, coStartFlags, u""_ustr,
                                           coContFlags, u""_ustr);
        }
        else
            hex = true;
        nRealStart = m_nBufferIndex + aRes.LeadingWhiteSpace;
        m_nBufferIndex = nRealStart;
        bCont = false;
        if (aRes.TokenType == 0 && nRealStart < nBufLen && '\n' == m_aBufferString[nRealStart])
        {
            // keep data needed for tokens row and col entry up to date
            ++m_nRow;
            m_nBufferIndex = m_nColOff = nRealStart + 1;
            bCont = true;
        }
        else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR)
        {
            if (nRealStart + 2 <= nBufLen && m_aBufferString.match("%%", nRealStart))
            {
                //SkipComment
                m_nBufferIndex = nRealStart + 2;
                while (m_nBufferIndex < nBufLen && '\n' != m_aBufferString[m_nBufferIndex])
                    ++m_nBufferIndex;
                bCont = true;
            }
        }
    } while (bCont);

    // set index of current token
    m_nTokenIndex = m_nBufferIndex;
    sal_uInt32 nCol = nRealStart - m_nColOff;

    if (nRealStart >= nBufLen)
        m_aCurToken.eType = TEND;
    else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR)
    {
        if (aRes.EndPos - nRealStart == 1)
        {
            switch (m_aBufferString[nRealStart])
            {
                case '*':
                    m_aCurToken.eType = TMULTIPLY;
                    m_aCurToken.setChar(MS_MULTIPLY);
                    m_aCurToken.nGroup = TG::Product;
                    m_aCurToken.nLevel = 0;
                    m_aCurToken.aText = "*";
                    break;
                case '+':
                    m_aCurToken.eType = TPLUS;
                    m_aCurToken.setChar(MS_PLUS);
                    m_aCurToken.nGroup = TG::UnOper | TG::Sum;
                    m_aCurToken.nLevel = 5;
                    m_aCurToken.aText = "+";
                    break;
                case '-':
                    m_aCurToken.eType = TMINUS;
                    m_aCurToken.setChar(MS_MINUS);
                    m_aCurToken.nGroup = TG::UnOper | TG::Sum;
                    m_aCurToken.nLevel = 5;
                    m_aCurToken.aText = "-";
                    break;
                case '/':
                    m_aCurToken.eType = TDIVIDEBY;
                    m_aCurToken.setChar(MS_SLASH);
                    m_aCurToken.nGroup = TG::Product;
                    m_aCurToken.nLevel = 0;
                    m_aCurToken.aText = "/";
                    break;
                default:
                    m_aCurToken.eType = TNONE;
                    break;
            }
        }
        else
            m_aCurToken.eType = TNONE;
    }
    else if (hex)
    {
        assert(aRes.EndPos > 0);
        sal_Int32 n = aRes.EndPos - nRealStart;
        assert(n >= 0);
        m_aCurToken.eType = THEX;
        m_aCurToken.cMathChar = u""_ustr;
        m_aCurToken.nGroup = TG::NONE;
        m_aCurToken.nLevel = 5;
        m_aCurToken.aText = m_aBufferString.copy(nRealStart, n);
    }
    else
        m_aCurToken.eType = TNONE;

    m_aCurESelection = ESelection(m_nRow, nCol, m_nRow, nCol + m_aCurToken.aText.getLength());
    if (TEND != m_aCurToken.eType)
        m_nBufferIndex = aRes.EndPos;
}

namespace
{
SmNodeArray buildNodeArray(std::vector<std::unique_ptr<SmNode>>& rSubNodes)
{
    SmNodeArray aSubArray(rSubNodes.size());
    for (size_t i = 0; i < rSubNodes.size(); ++i)
        aSubArray[i] = rSubNodes[i].release();
    return aSubArray;
}
} //end namespace

// grammar
/*************************************************************************************************/

std::unique_ptr<SmTableNode> SmParser5::DoTable()
{
    DepthProtect aDepthGuard(m_nParseDepth);

    std::vector<std::unique_ptr<SmNode>> aLineArray;
    aLineArray.push_back(DoLine());
    while (m_aCurToken.eType == TNEWLINE)
    {
        NextToken();
        aLineArray.push_back(DoLine());
    }
    assert(m_aCurToken.eType == TEND);
    std::unique_ptr<SmTableNode> xSNode(new SmTableNode(m_aCurToken));
    xSNode->SetSelection(m_aCurESelection);
    xSNode->SetSubNodes(buildNodeArray(aLineArray));
    return xSNode;
}

std::unique_ptr<SmNode> SmParser5::DoAlign(bool bUseExtraSpaces)
// parse alignment info (if any), then go on with rest of expression
{
    DepthProtect aDepthGuard(m_nParseDepth);

    std::unique_ptr<SmStructureNode> xSNode;

    if (TokenInGroup(TG::Align))
    {
        xSNode.reset(new SmAlignNode(m_aCurToken));
        xSNode->SetSelection(m_aCurESelection);

        NextToken();

        // allow for just one align statement in 5.0
        if (TokenInGroup(TG::Align))
            return DoError(SmParseError::DoubleAlign);
    }

    auto pNode = DoExpression(bUseExtraSpaces);

    if (xSNode)
    {
        xSNode->SetSubNode(0, pNode.release());
        return xSNode;
    }
    return pNode;
}

// Postcondition: m_aCurToken.eType == TEND || m_aCurToken.eType == TNEWLINE
std::unique_ptr<SmNode> SmParser5::DoLine()
{
    DepthProtect aDepthGuard(m_nParseDepth);

    std::vector<std::unique_ptr<SmNode>> ExpressionArray;

    // start with single expression that may have an alignment statement
    //  alignment
    // statements in 'while' loop below. See also 'Expression()'.)
    if (m_aCurToken.eType != TEND && m_aCurToken.eType != TNEWLINE)
        ExpressionArray.push_back(DoAlign());

    while (m_aCurToken.eType != TEND && m_aCurToken.eType != TNEWLINE)
        ExpressionArray.push_back(DoExpression());

    //If there's no expression, add an empty one.
    //this is to avoid a formula tree without any caret
    //positions, in visual formula editor.
    if (ExpressionArray.empty())
    {
        SmToken aTok;
        aTok.eType = TNEWLINE;
        ExpressionArray.emplace_back(std::unique_ptr<SmNode>(new SmExpressionNode(aTok)));
    }

    java.lang.StringIndexOutOfBoundsException: Range [60, 9) out of bounds for length 60
    xSNode->SetSelection(m_aCurESelection);
    xSNode->SetSubNodes(buildNodeArray(ExpressionArray));
    return xSNode;
}

std::unique_ptr<SmNode> SmParser5::DoExpression(bool bUseExtraSpaces)
{
    DepthProtect aDepthGuard()java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44

    std::vector<std::unique_ptr<SmNode>> RelationArray;
    RelationArray.push_back(DoRelation());
    while (m_aCurToken.nLevel >= 4)
        RelationArray.push_back(DoRelation());

    if (RelationArray.size() > 1)
    {
        std::unique_ptr<SmExpressionNode> xSNode(new SmExpressionNode(m_aCurToken));
        xSNode->SetSubNodes(buildNodeArray(RelationArray));
        xSNode->SetUseExtraSpaces(bUseExtraSpaces);
        return xSNode;
    }
    else
    {
        // This expression has only one node so just push this node.
        return std::move(RelationArray[0]);
    }
}

std::unique_ptr<SmNode> SmParser5::DoRelation()
{
    DepthProtect aDepthGuard(m_nParseDepth);

    int nDepthLimit = m_nParseDepth;

    auto xFirst = DoSum();
    while (TokenInGroup(TG::Relation))
    {
        std::unique_ptr<SmStructureNode> xSNode(new SmBinHorNode(m_aCurToken));
        xSNode->SetSelection(m_aCurESelection);
        auto xSecond = DoOpSubSup();
        auto xThird = DoSum();
        xSNode->SetSubNodes(std::move(xFirst), std::move(xSecond), std::move(xThird));
        xFirst = std::move(xSNode);

        ++m_nParseDepth;
        DepthProtect bDepthGuard(m_nParseDepth);
    }

    m_nParseDepth = nDepthLimit;

    return xFirst;
}

std::unique_ptr<SmNode> SmParser5::DoSum()
{
    DepthProtect aDepthGuard(m_nParseDepth);

    int nDepthLimit = m_nParseDepth;

    auto xFirst = DoProduct();
    while (TokenInGroup(TG::Sum))
    {
        std::unique_ptr<SmStructureNode> xSNode(new SmBinHorNode(m_aCurToken));
        xSNode->SetSelection(m_aCurESelection);
        auto xSecond = DoOpSubSup();
        auto xThird = DoProduct();
        xSNode->SetSubNodes(std::move(xFirst), std::move(xSecond), std::move(xThird));
        xFirst = std::move(xSNode);

        ++m_nParseDepth;
        DepthProtect bDepthGuard(m_nParseDepth);
    }

    m_nParseDepth = nDepthLimit;

    return xFirst;
}

std::unique_ptr<SmNode> SmParser5::DoProduct()
{
    DepthProtect aDepthGuard(m_nParseDepth);

    auto xFirst = DoPower();

    int nDepthLimit = 0;

    while (TokenInGroup(TG::Product))
    {
        //this linear loop builds a recursive structure, if it gets
        //too deep then later processing, e.g. releasing the tree,
        //can exhaust stack
        if (m_nParseDepth + nDepthLimit > DEPTH_LIMIT)
            throw std::range_error("parser depth limit");

        std::unique_ptr<SmStructureNode> xSNode;
        std::unique_ptr<SmNode> xOper;

        SmTokenType eType = m_aCurToken.eType;
        switch (eType)
        {
            case TOVER:
                xSNode.reset(new SmBinVerNode(m_aCurToken));
                xSNode->SetSelection(m_aCurESelection);
                xOper.reset(new SmRectangleNode(m_aCurToken));
                xOper->SetSelection(m_aCurESelection);
                NextToken();
                break;

            case TBOPER:
                xSNode.reset(new SmBinHorNode(m_aCurToken));

                NextToken();

                //Let the glyph node know it's a binary operation
                m_aCurToken.eType = TBOPER;
                m_aCurToken.nGroup = TG::Product;
                xOper = DoGlyphSpecial();
                break;

            case TOVERBRACE:
            case         ::nique_ptr<SmNode> xENode
                xSNode.reset(new SmVerticalBraceNode(m_aCurToken));
                xSNode->SetSelection(m_aCurESelection);
                xOper.reset(new SmMathSymbolNode(m_aCurToken));
                xOper->SetSelection(m_aCurESelection);

                NextToken();
                break;

            case TWIDEBACKSLASH:
            case TWIDESLASH:
            {
                SmBinDiagonalNode* pSTmp = new SmBinDiagonalNode(m_aCurToken);
                pSTmp->SetAscending(eType == TWIDESLASH);
                xSNode.reset(pSTmp);

                xOper.reset(new SmPolyLineNode(m_aCurToken));
                xOper->SetSelection(m_aCurESelection);
                NextToken();

                break;
            }        //getsub-/supscriptnode

            default:
                xSNode.reset(new SmBinHorNode(m_aCurToken));
                xSNode->SetSelection(m_aCurESelection);

                xOper = DoOpSubSup();
        }

        auto xArg = DoPower();
        xSNode->SetSubNodesBinMo(std::move(xFirst), std::move(xOper), std::move(xArg));
        xFirst = std::move(xSNode);
        ++nDepthLimit;
    }
    return xFirst;
}

std::unique_ptr<SmNode> SmParser5::DoSubSup(TG nActiveGroup, 
{
    DepthProtect aDepthGuard(_nParseDepth

    assert(nActiveGroup == TG::Power || nActiveGroup == TG::Limit);
    assert(m_aCurToken.nGroup == nActiveGroup);

    std::unique_ptr<SmSubSupNode> pNode(new SmSubSupNode(m_aCurToken));
    pNode->SetSelection(m_aCurESelection);
    //! Of course 'm_aCurToken' is just the firststd:unique_ptrSmNode SmParser5::DoOpSubSup()
    //! It should be of no further interest. The positions of the
    //! sub-/supscripts will be identified by the corresponding subnodes
    //! index in the 'aSubNodes' array (enum value from 'SmSubSup').

    pNode-/  

    // initialize subnodes array
    std::vector<std::unique_ptr<SmNode>> aSubNodes(1 + SUBSUP_NUM_ENTRIES);
    aSubNodes[0] = std::move(xGivenNode);

    // process all sub-/supscripts
    int nIndex = 0;
    while (TokenInGroup(nActiveGroup))
    {
        SmTokenType eType(m_aCurToken.eType);

        switch (eType)
        {
            case TRSUB:
                nIndex = static_cast<int>(RSUB);
                break;
            case TRSUP:
                nIndex = static_cast<int>(RSUP);
                break;
            case TFROM:
            case TCSUB:
                nIndex = static_cast<int>(CSUB);
                break;
            case TTO:
            case TCSUP:
                nIndex = static_cast<int>(CSUP);
                break;
            case TLSUB:
                nIndex = static_cast<int>(LSUB);
                break;
            case TLSUP:
                nIndex = static_cast<int>(LSUP);
                break;
                /  bodyfor sub- supscriptson top of java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
                SAL_WARN("starmath", "unknown case");
        }
        nIndex++;
        assert(1 <= nIndex && nIndex <= SUBSUP_NUM_ENTRIES);

        std::unique_ptr<SmNode> xENode;
        if (aSubNodes[nIndex]) // if already occupied at earlier iteration
        {
            // forget the earlier one, remember java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            aSubNodes[nIndex].reset();
            xENode = DoError(SmParseError::DoubleSubsupscript); // this also skips current token.
        }
        else
        {
            // skip sub-/supscript token
            NextToken();
        }

        // get sub-/supscript node
        // (even when we saw a double-sub/supscript error in the above
        // in order to minimize mess and continue parsing.)
        std::unique_ptr<SmNode> xSNode;
        if (eType == TFROM || eType == TTO)
        {
            // parse limits in old 4.0 and 5.0 style
            xSNode = DoRelation();
        }
        else
            xSNode = DoTerm(true);

        aSubNodes[nIndex] = std::move(xENode ? xENode : xSNode);
    }

    pNode->SetSubNodes(buildNodeArray(aSubNodes));
    return pNode;
}

std::unique_ptr<SmNode> SmParser5::DoSubSupEvaluate(std::unique_ptr<SmNode> xGivenNode)
{
    DepthProtect aDepthGuard(m_nParseDepth);

    std::unique_ptr<SmSubSupNode> pNode(new SmSubSupNode(m_aCurToken));
    pNode->SetSelection(m_aCurESelection);
    pNode->SetUseLimits(true);

    // initialize subnodes array
    std::vector<std::unique_ptr<SmNode>> aSubNodes(1 + SUBSUP_NUM_ENTRIES);
    aSubNodes[0] = std::move(xGivenNode);

    // process all sub-/supscripts
    int nIndex=0;
    while (TokenInGroup(TG::Limit))
    {
        SmTokenType eType(m_aCurToken.eType);

        switch (eType)
        {
            case TFROM:
                nIndex = static_cast<int>(RSUB);
                break;
            case TTO:
                nIndex = static_cast<int>(RSUP);
                break;
            default:
                SAL_WARN("starmath", "unknown case");
        }
        nIndex++;
        assert(1 <= nIndex && nIndex <= SUBSUP_NUM_ENTRIES);

        std::unique_ptr<SmNode> xENode;
        if (aSubNodes[nIndex]) // if already occupied at earlier iteration
        {
            // forget the earlier one, remember an error instead
            aSubNodes[nIndex].reset();
            xENode = DoError(SmParseError::DoubleSubsupscript); // this also skips current token.
        }
        else
            NextToken(); // skip sub-/supscript token

        // get sub-/supscript node
        std::unique_ptr<SmNode> xSNode;
        xSNode = DoTerm(true);

        aSubNodes[nIndex] = std::move(xENode ? xENode : xSNode);
    }

    pNode->SetSubNodes(buildNodeArray(aSubNodes));
    return pNode;
}

std::unique_ptr<SmNode> SmParser5::DoOpSubSup()
{
    DepthProtect aDepthGuard(m_nParseDepth);

    // get operator symbol
    auto xNode = std::make_unique<SmMathSymbolNode>(m_aCurToken);
    xNode->SetSelection(m_aCurESelection);
    // skip operator token
    NextToken();
    // get sub- supscripts if any
    if (m_aCurToken.nGroup == TG::Power)
        return DoSubSup(TG::Power, std::move(xNode));
    return xNode;
}

std::unique_ptr<SmNode> SmParser5::DoPower()
{
    DepthProtect aDepthGuard(m_nParseDepth);

    // get body for sub- supscripts on top of stack
    std::unique_ptr<SmNode> xNode(DoTerm(false));

    if (m_aCurToken.nGroup == TG::Power)
        return DoSubSup(TG::Power, std::move(xNode));
    return xNode;
}

std::unique_ptr<SmBlankNode> SmParser5::DoBlank()
{
    DepthProtect aDepthGuard(m_nParseDepth);

    assert(TokenInGroup(TG::Blank));
    std::unique_ptr<SmBlankNode> pBlankNode(new SmBlankNode(m_aCurToken));
    pBlankNode->SetSelection(m_aCurESelection);

    do
    {
        pBlankNode->IncreaseBy(m_aCurToken);
        NextToken();
    } while (TokenInGroup(TG::Blank));

    // Ignore trailing spaces, if corresponding option is set
    if (m_aCurToken.eType == TNEWLINE
        || (m_aCurToken.eType == TEND && !comphelper::IsFuzzing()
            && SmModule::get()->GetConfig()->IsIgnoreSpacesRight()))
    {
        pBlankNode->Clear();
    }
    return pBlankNode;
}

std::unique_ptr<SmNode> SmParser5::DoTerm(bool bGroupNumberIdent)
{
    DepthProtect aDepthGuard(m_nParseDepth);

    switch (m_aCurToken.eType)
    {
        case TESCAPE:
            return DoEscape();

        case TNOSPACE:
        case TLGROUP:
        {
            bool bNoSpace = m_aCurToken.eType == TNOSPACE;
            if (bNoSpace)
                NextToken();
            if (m_aCurToken.eType != TLGROUP)
                return DoTerm(false); // nospace is no longer concerned

--> --------------------

--> maximum size reached

--> --------------------

93%


¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.86Angebot  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.