diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-11-09 00:14:29 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-11-09 00:27:01 +0900 |
commit | c1358e5dc875bb923f4b5472ba615ebd19f0d057 (patch) | |
tree | 84341e9a25ac5805a946f17c2bdaf83863271f48 | |
parent | 1da74e727d7f8703006cfe574b26621d5f674693 (diff) |
separate parse.hxx into smaller parts
... so that node.hxx no longer needs to include parse.hxx.
Change-Id: Iac1e21c208e3f0e3fd8ece16eee345e81574a0aa
-rw-r--r-- | starmath/inc/error.hxx | 55 | ||||
-rw-r--r-- | starmath/inc/node.hxx | 5 | ||||
-rw-r--r-- | starmath/inc/parse.hxx | 146 | ||||
-rw-r--r-- | starmath/inc/token.hxx | 135 | ||||
-rw-r--r-- | starmath/source/cursor.cxx | 1 | ||||
-rw-r--r-- | starmath/source/parse.cxx | 2 |
6 files changed, 197 insertions, 147 deletions
diff --git a/starmath/inc/error.hxx b/starmath/inc/error.hxx new file mode 100644 index 000000000000..9d3dc3026313 --- /dev/null +++ b/starmath/inc/error.hxx @@ -0,0 +1,55 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_STARMATH_INC_ERROR_HXX +#define INCLUDED_STARMATH_INC_ERROR_HXX + +#include <rtl/ustring.hxx> + +#include <boost/ptr_container/ptr_vector.hpp> + +class SmNode; + +enum SmParseError +{ + PE_NONE, PE_UNEXPECTED_END_OF_INPUT, + PE_UNEXPECTED_CHAR, PE_UNEXPECTED_TOKEN, + PE_FUNC_EXPECTED, PE_UNOPER_EXPECTED, + PE_BINOPER_EXPECTED, PE_SYMBOL_EXPECTED, + PE_IDENTIFIER_EXPECTED, PE_POUND_EXPECTED, + PE_COLOR_EXPECTED, PE_LGROUP_EXPECTED, + PE_RGROUP_EXPECTED, PE_LBRACE_EXPECTED, + PE_RBRACE_EXPECTED, PE_PARENT_MISMATCH, + PE_RIGHT_EXPECTED, PE_FONT_EXPECTED, + PE_SIZE_EXPECTED, PE_DOUBLE_ALIGN, + PE_DOUBLE_SUBSUPSCRIPT +}; + + +struct SmErrorDesc +{ + SmParseError Type; + SmNode *pNode; + OUString Text; +}; + +typedef boost::ptr_vector< SmErrorDesc > SmErrDescList; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx index 220e30d2ffc9..7949779f4ac9 100644 --- a/starmath/inc/node.hxx +++ b/starmath/inc/node.hxx @@ -23,9 +23,11 @@ #include <vector> #include <ostream> #include <stdio.h> +#include <stack> -#include "parse.hxx" #include "types.hxx" +#include "token.hxx" +#include "error.hxx" #include "rect.hxx" #include "format.hxx" @@ -58,6 +60,7 @@ class SmNode; class SmStructureNode; typedef boost::shared_ptr<SmNode> SmNodePointer; +typedef std::stack< SmNode* > SmNodeStack; typedef std::vector< SmNode * > SmNodeArray; typedef std::vector< SmStructureNode * > SmStructureNodeArray; diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index c74099114284..c61bf42372c0 100644 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -22,153 +22,13 @@ #include <vcl/svapp.hxx> #include <set> -#include <stack> #include "types.hxx" +#include "token.hxx" +#include "error.hxx" +#include "node.hxx" #include <boost/noncopyable.hpp> -#include <boost/ptr_container/ptr_vector.hpp> - -class SmNode; - - - -// TokenGroups -#define TGOPER 0x00000001 -#define TGRELATION 0x00000002 -#define TGSUM 0x00000004 -#define TGPRODUCT 0x00000008 -#define TGUNOPER 0x00000010 -#define TGPOWER 0x00000020 -#define TGATTRIBUT 0x00000040 -#define TGALIGN 0x00000080 -#define TGFUNCTION 0x00000100 -#define TGBLANK 0x00000200 -#define TGLBRACES 0x00000400 -#define TGRBRACES 0x00000800 -#define TGCOLOR 0x00001000 -#define TGFONT 0x00002000 -#define TGSTANDALONE 0x00004000 -#define TGDISCARDED 0x00008000 -#define TGLIMIT 0x00010000 -#define TGFONTATTR 0x00020000 - - -enum SmTokenType -{ -/* 0*/ TEND, TLGROUP, TRGROUP, TLPARENT, TRPARENT, -/* 5*/ TLBRACKET, TRBRACKET, TPLUS, TMINUS, TMULTIPLY, -/* 10*/ TDIVIDEBY, TASSIGN, TPOUND, TSPECIAL, TSLASH, -/* 15*/ TBACKSLASH, TBLANK, TSBLANK, TRSUB, TRSUP, -/* 20*/ TCSUB, TCSUP, TLSUB, TLSUP, TGT, -/* 25*/ TLT, TAND, TOR, TINTERSECT, TUNION, -/* 30*/ TNEWLINE, TBINOM, TFROM, TTO, TINT, -/* 35*/ TSUM, TOPER, TABS, TSQRT, TFACT, -/* 40*/ TNROOT, TOVER, TTIMES, TGE, TLE, -/* 45*/ TGG, TLL, TDOTSAXIS, TDOTSLOW, TDOTSVERT, -/* 50*/ TDOTSDIAG, TDOTSUP, TDOTSDOWN, TACUTE, TBAR, -/* 55*/ TBREVE, TCHECK, TCIRCLE, TDOT, TDDOT, -/* 60*/ TDDDOT, TGRAVE, THAT, TTILDE, TVEC, -/* 65*/ TUNDERLINE, TOVERLINE, TOVERSTRIKE, TITALIC, TNITALIC, -/* 70*/ TBOLD, TNBOLD, TPHANTOM, TFONT, TSIZE, -/* 75*/ TCOLOR, TALIGNL, TALIGNC, TALIGNR, TLEFT, -/* 80*/ TRIGHT, TLANGLE, TLBRACE, TLLINE, TLDLINE, -/* 85*/ TLCEIL, TLFLOOR, TNONE, TMLINE, TRANGLE, -/* 90*/ TRBRACE, TRLINE, TRDLINE, TRCEIL, TRFLOOR, -/* 95*/ TSIN, TCOS, TTAN, TCOT, TFUNC, -/*100*/ TSTACK, TMATRIX, TMATFORM, TDPOUND, TPLACE, -/*105*/ TTEXT, TNUMBER, TCHARACTER, TIDENT, TNEQ, -/*110*/ TEQUIV, TDEF, TPROP, TSIM, TSIMEQ, -/*115*/ TAPPROX, TPARALLEL, TORTHO, TIN, TNOTIN, -/*120*/ TSUBSET, TSUBSETEQ, TSUPSET, TSUPSETEQ, TPLUSMINUS, -/*125*/ TMINUSPLUS, TOPLUS, TOMINUS, TDIV, TOTIMES, -/*130*/ TODIVIDE, TTRANSL, TTRANSR, TIINT, TIIINT, -/*135*/ TLINT, TLLINT, TLLLINT, TPROD, TCOPROD, -/*140*/ TFORALL, TEXISTS, TNOTEXISTS, TLIM, TNABLA, -/*145*/ TTOWARD, TSINH, TCOSH, TTANH, TCOTH, -/*150*/ TASIN, TACOS, TATAN, TLN, TLOG, -/*155*/ TUOPER, TBOPER, TBLACK, TWHITE, TRED, -/*160*/ TGREEN, TBLUE, TCYAN, TMAGENTA, TYELLOW, -/*165*/ TFIXED, TSANS, TSERIF, TPOINT, TASINH, -/*170*/ TACOSH, TATANH, TACOTH, TACOT, TEXP, -/*175*/ TCDOT, TODOT, TLESLANT, TGESLANT, TNSUBSET, -/*180*/ TNSUPSET, TNSUBSETEQ, TNSUPSETEQ, TPARTIAL, TNEG, -/*185*/ TNI, TBACKEPSILON, TALEPH, TIM, TRE, -/*190*/ TWP, TEMPTYSET, TINFINITY, TESCAPE, TLIMSUP, -/*195*/ TLIMINF, TNDIVIDES, TDRARROW, TDLARROW, TDLRARROW, -/*200*/ TUNDERBRACE, TOVERBRACE, TCIRC, TTOP, THBAR, -/*205*/ TLAMBDABAR, TLEFTARROW, TRIGHTARROW, TUPARROW, TDOWNARROW, -/*210*/ TDIVIDES, TNDIBVIDES, TSETN, TSETZ, TSETQ, -/*215*/ TSETR, TSETC, TWIDEVEC, TWIDETILDE, TWIDEHAT, -/*220*/ TWIDESLASH, TWIDEBACKSLASH, TLDBRACKET, TRDBRACKET, TNOSPACE, -/*225*/ TUNKNOWN, TDEBUG, TPRECEDES, TSUCCEEDS, TPRECEDESEQUAL, -/*230*/ TSUCCEEDSEQUAL, TPRECEDESEQUIV, TSUCCEEDSEQUIV, TNOTPRECEDES, TNOTSUCCEEDS, -/*235*/ TSILVER, TGRAY, TMAROON, TPURPLE, TLIME, -/*240*/ TOLIVE, TNAVY, TTEAL, TAQUA, TFUCHSIA, -/*245*/ TINTD -}; - -struct SmToken -{ - - OUString aText; // token text - SmTokenType eType; // token info - sal_Unicode cMathChar; - - // parse-help info - sal_uLong nGroup; - sal_uInt16 nLevel; - - // token position - sal_Int32 nRow; - sal_Int32 nCol; - - SmToken(); - SmToken(SmTokenType eTokenType, - sal_Unicode cMath, - const sal_Char* pText, - sal_uLong nTokenGroup = 0, - sal_uInt16 nTokenLevel = 0); -}; - - -enum SmParseError -{ - PE_NONE, PE_UNEXPECTED_END_OF_INPUT, - PE_UNEXPECTED_CHAR, PE_UNEXPECTED_TOKEN, - PE_FUNC_EXPECTED, PE_UNOPER_EXPECTED, - PE_BINOPER_EXPECTED, PE_SYMBOL_EXPECTED, - PE_IDENTIFIER_EXPECTED, PE_POUND_EXPECTED, - PE_COLOR_EXPECTED, PE_LGROUP_EXPECTED, - PE_RGROUP_EXPECTED, PE_LBRACE_EXPECTED, - PE_RBRACE_EXPECTED, PE_PARENT_MISMATCH, - PE_RIGHT_EXPECTED, PE_FONT_EXPECTED, - PE_SIZE_EXPECTED, PE_DOUBLE_ALIGN, - PE_DOUBLE_SUBSUPSCRIPT -}; - - -struct SmErrorDesc -{ - SmParseError Type; - SmNode *pNode; - OUString Text; -}; - - -typedef ::std::stack< SmNode* > SmNodeStack; -typedef boost::ptr_vector< SmErrorDesc > SmErrDescList; - -/**************************************************************************/ - -struct SmTokenTableEntry -{ - const sal_Char* pIdent; - SmTokenType eType; - sal_Unicode cMathChar; - sal_uLong nGroup; - sal_uInt16 nLevel; -}; class SmParser : boost::noncopyable { diff --git a/starmath/inc/token.hxx b/starmath/inc/token.hxx new file mode 100644 index 000000000000..ec01bcf65030 --- /dev/null +++ b/starmath/inc/token.hxx @@ -0,0 +1,135 @@ +/* -*- 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 . + */ +#ifndef INCLUDED_STARMATH_INC_TOKEN_HXX +#define INCLUDED_STARMATH_INC_TOKEN_HXX + +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <tools/solar.h> + +// TokenGroups +#define TGOPER 0x00000001 +#define TGRELATION 0x00000002 +#define TGSUM 0x00000004 +#define TGPRODUCT 0x00000008 +#define TGUNOPER 0x00000010 +#define TGPOWER 0x00000020 +#define TGATTRIBUT 0x00000040 +#define TGALIGN 0x00000080 +#define TGFUNCTION 0x00000100 +#define TGBLANK 0x00000200 +#define TGLBRACES 0x00000400 +#define TGRBRACES 0x00000800 +#define TGCOLOR 0x00001000 +#define TGFONT 0x00002000 +#define TGSTANDALONE 0x00004000 +#define TGDISCARDED 0x00008000 +#define TGLIMIT 0x00010000 +#define TGFONTATTR 0x00020000 + + +enum SmTokenType +{ +/* 0*/ TEND, TLGROUP, TRGROUP, TLPARENT, TRPARENT, +/* 5*/ TLBRACKET, TRBRACKET, TPLUS, TMINUS, TMULTIPLY, +/* 10*/ TDIVIDEBY, TASSIGN, TPOUND, TSPECIAL, TSLASH, +/* 15*/ TBACKSLASH, TBLANK, TSBLANK, TRSUB, TRSUP, +/* 20*/ TCSUB, TCSUP, TLSUB, TLSUP, TGT, +/* 25*/ TLT, TAND, TOR, TINTERSECT, TUNION, +/* 30*/ TNEWLINE, TBINOM, TFROM, TTO, TINT, +/* 35*/ TSUM, TOPER, TABS, TSQRT, TFACT, +/* 40*/ TNROOT, TOVER, TTIMES, TGE, TLE, +/* 45*/ TGG, TLL, TDOTSAXIS, TDOTSLOW, TDOTSVERT, +/* 50*/ TDOTSDIAG, TDOTSUP, TDOTSDOWN, TACUTE, TBAR, +/* 55*/ TBREVE, TCHECK, TCIRCLE, TDOT, TDDOT, +/* 60*/ TDDDOT, TGRAVE, THAT, TTILDE, TVEC, +/* 65*/ TUNDERLINE, TOVERLINE, TOVERSTRIKE, TITALIC, TNITALIC, +/* 70*/ TBOLD, TNBOLD, TPHANTOM, TFONT, TSIZE, +/* 75*/ TCOLOR, TALIGNL, TALIGNC, TALIGNR, TLEFT, +/* 80*/ TRIGHT, TLANGLE, TLBRACE, TLLINE, TLDLINE, +/* 85*/ TLCEIL, TLFLOOR, TNONE, TMLINE, TRANGLE, +/* 90*/ TRBRACE, TRLINE, TRDLINE, TRCEIL, TRFLOOR, +/* 95*/ TSIN, TCOS, TTAN, TCOT, TFUNC, +/*100*/ TSTACK, TMATRIX, TMATFORM, TDPOUND, TPLACE, +/*105*/ TTEXT, TNUMBER, TCHARACTER, TIDENT, TNEQ, +/*110*/ TEQUIV, TDEF, TPROP, TSIM, TSIMEQ, +/*115*/ TAPPROX, TPARALLEL, TORTHO, TIN, TNOTIN, +/*120*/ TSUBSET, TSUBSETEQ, TSUPSET, TSUPSETEQ, TPLUSMINUS, +/*125*/ TMINUSPLUS, TOPLUS, TOMINUS, TDIV, TOTIMES, +/*130*/ TODIVIDE, TTRANSL, TTRANSR, TIINT, TIIINT, +/*135*/ TLINT, TLLINT, TLLLINT, TPROD, TCOPROD, +/*140*/ TFORALL, TEXISTS, TNOTEXISTS, TLIM, TNABLA, +/*145*/ TTOWARD, TSINH, TCOSH, TTANH, TCOTH, +/*150*/ TASIN, TACOS, TATAN, TLN, TLOG, +/*155*/ TUOPER, TBOPER, TBLACK, TWHITE, TRED, +/*160*/ TGREEN, TBLUE, TCYAN, TMAGENTA, TYELLOW, +/*165*/ TFIXED, TSANS, TSERIF, TPOINT, TASINH, +/*170*/ TACOSH, TATANH, TACOTH, TACOT, TEXP, +/*175*/ TCDOT, TODOT, TLESLANT, TGESLANT, TNSUBSET, +/*180*/ TNSUPSET, TNSUBSETEQ, TNSUPSETEQ, TPARTIAL, TNEG, +/*185*/ TNI, TBACKEPSILON, TALEPH, TIM, TRE, +/*190*/ TWP, TEMPTYSET, TINFINITY, TESCAPE, TLIMSUP, +/*195*/ TLIMINF, TNDIVIDES, TDRARROW, TDLARROW, TDLRARROW, +/*200*/ TUNDERBRACE, TOVERBRACE, TCIRC, TTOP, THBAR, +/*205*/ TLAMBDABAR, TLEFTARROW, TRIGHTARROW, TUPARROW, TDOWNARROW, +/*210*/ TDIVIDES, TNDIBVIDES, TSETN, TSETZ, TSETQ, +/*215*/ TSETR, TSETC, TWIDEVEC, TWIDETILDE, TWIDEHAT, +/*220*/ TWIDESLASH, TWIDEBACKSLASH, TLDBRACKET, TRDBRACKET, TNOSPACE, +/*225*/ TUNKNOWN, TDEBUG, TPRECEDES, TSUCCEEDS, TPRECEDESEQUAL, +/*230*/ TSUCCEEDSEQUAL, TPRECEDESEQUIV, TSUCCEEDSEQUIV, TNOTPRECEDES, TNOTSUCCEEDS, +/*235*/ TSILVER, TGRAY, TMAROON, TPURPLE, TLIME, +/*240*/ TOLIVE, TNAVY, TTEAL, TAQUA, TFUCHSIA, +/*245*/ TINTD +}; + +struct SmToken +{ + + OUString aText; // token text + SmTokenType eType; // token info + sal_Unicode cMathChar; + + // parse-help info + sal_uLong nGroup; + sal_uInt16 nLevel; + + // token position + sal_Int32 nRow; + sal_Int32 nCol; + + SmToken(); + SmToken(SmTokenType eTokenType, + sal_Unicode cMath, + const sal_Char* pText, + sal_uLong nTokenGroup = 0, + sal_uInt16 nTokenLevel = 0); +}; + +struct SmTokenTableEntry +{ + const sal_Char* pIdent; + SmTokenType eType; + sal_Unicode cMathChar; + sal_uLong nGroup; + sal_uInt16 nLevel; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index c29d009b34fd..60c0ed97337e 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -7,7 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "cursor.hxx" -#include "parse.hxx" #include "visitors.hxx" #include "document.hxx" #include "view.hxx" diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index c1757bf20768..25a1c6cb2b62 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -32,8 +32,6 @@ #include "smmod.hxx" #include "config.hxx" -#include "node.hxx" - using namespace ::com::sun::star; using namespace ::com::sun::star::i18n; |