diff options
Diffstat (limited to 'autodoc/source/parser_i/tokens')
-rw-r--r-- | autodoc/source/parser_i/tokens/makefile.mk | 67 | ||||
-rw-r--r-- | autodoc/source/parser_i/tokens/stmstar2.cxx | 105 | ||||
-rw-r--r-- | autodoc/source/parser_i/tokens/stmstat2.cxx | 49 | ||||
-rw-r--r-- | autodoc/source/parser_i/tokens/stmstfi2.cxx | 64 | ||||
-rw-r--r-- | autodoc/source/parser_i/tokens/tkp2.cxx | 65 | ||||
-rw-r--r-- | autodoc/source/parser_i/tokens/tkpcont2.cxx | 68 | ||||
-rw-r--r-- | autodoc/source/parser_i/tokens/tkpstam2.cxx | 177 | ||||
-rw-r--r-- | autodoc/source/parser_i/tokens/x_parse2.cxx | 64 |
8 files changed, 659 insertions, 0 deletions
diff --git a/autodoc/source/parser_i/tokens/makefile.mk b/autodoc/source/parser_i/tokens/makefile.mk new file mode 100644 index 000000000000..64413dd085ae --- /dev/null +++ b/autodoc/source/parser_i/tokens/makefile.mk @@ -0,0 +1,67 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.3 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=garden +TARGET=parser2_tokens +TARGETTYPE=CUI + + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true +PRJINC=$(PRJ)$/source + + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/source$/mkinc$/fullcpp.mk + + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/stmstar2.obj \ + $(OBJ)$/stmstat2.obj \ + $(OBJ)$/stmstfi2.obj \ + $(OBJ)$/tkpstam2.obj \ + $(OBJ)$/tkp2.obj \ + $(OBJ)$/tkpcont2.obj \ + $(OBJ)$/x_parse2.obj + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/autodoc/source/parser_i/tokens/stmstar2.cxx b/autodoc/source/parser_i/tokens/stmstar2.cxx new file mode 100644 index 000000000000..8d0fb2cb0460 --- /dev/null +++ b/autodoc/source/parser_i/tokens/stmstar2.cxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: stmstar2.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <tokens/stmstar2.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <x_parse2.hxx> + + + +StmArrayStatu2::StmArrayStatu2( intt i_nStatusSize, + const INT16 * in_aArrayModel, + uintt i_nTokenId, + bool in_bIsDefault ) + : dpBranches(new StmStatu2::Branch[i_nStatusSize]), + nNrOfBranches(i_nStatusSize), + nTokenId(UINT16(i_nTokenId)), + bIsADefault(in_bIsDefault) +{ + // KORR_FUTURE: Interface of StmArrayStatu2() has to be changed. + csv_assert(i_nTokenId < 64536); + + if (in_aArrayModel != 0) + { + intt count = 0; + for (const INT16 * get = in_aArrayModel; count < nNrOfBranches; count++, get++) + dpBranches[count] = *get; + } + else // + { + memset(dpBranches, 0, nNrOfBranches); + } // endif +} + +StmArrayStatu2::~StmArrayStatu2() +{ + delete [] dpBranches; +} + +bool +StmArrayStatu2::SetBranch( intt in_nBranchIx, + StmStatu2::Branch in_nBranch ) +{ + if ( csv::in_range(intt(0), in_nBranchIx, intt(nNrOfBranches) ) ) + { + dpBranches[in_nBranchIx] = in_nBranch; + return true; + } + return false; +} + + +StmStatu2::Branch +StmArrayStatu2::NextBy(intt in_nIndex) const +{ + if (in_nIndex < 0) + throw X_AutodocParser(X_AutodocParser::x_InvalidChar); + + return in_nIndex < nNrOfBranches + ? dpBranches[in_nIndex] + : dpBranches[nNrOfBranches - 1]; +} + + +bool +StmArrayStatu2::IsADefault() const +{ + return bIsADefault; +} + +StmArrayStatu2 * +StmArrayStatu2::AsArray() +{ + return this; +} + diff --git a/autodoc/source/parser_i/tokens/stmstat2.cxx b/autodoc/source/parser_i/tokens/stmstat2.cxx new file mode 100644 index 000000000000..7a1acd599219 --- /dev/null +++ b/autodoc/source/parser_i/tokens/stmstat2.cxx @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: stmstat2.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <tokens/stmstat2.hxx> + + +// NOT FULLY DECLARED SERVICES + +StmArrayStatu2 * +StmStatu2::AsArray() +{ + return 0; +} + +StmBoundsStatu2 * +StmStatu2::AsBounds() +{ + return 0; +} + + diff --git a/autodoc/source/parser_i/tokens/stmstfi2.cxx b/autodoc/source/parser_i/tokens/stmstfi2.cxx new file mode 100644 index 000000000000..46cdf6666d64 --- /dev/null +++ b/autodoc/source/parser_i/tokens/stmstfi2.cxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: stmstfi2.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <tokens/stmstfi2.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <tokens/tkpcont2.hxx> + + +StmBoundsStatu2::StmBoundsStatu2( StateMachineContext & + o_rOwner, + TkpContext & i_rFollowUpContext, + uintt i_nStatusFunctionNr, + bool i_bIsDefault ) + : pOwner(&o_rOwner), + pFollowUpContext(&i_rFollowUpContext), + nStatusFunctionNr(i_nStatusFunctionNr), + bIsDefault(i_bIsDefault) +{ +} + +bool +StmBoundsStatu2::IsADefault() const +{ + return bIsDefault; +} + +StmBoundsStatu2 * +StmBoundsStatu2::AsBounds() +{ + return this; +} + + + diff --git a/autodoc/source/parser_i/tokens/tkp2.cxx b/autodoc/source/parser_i/tokens/tkp2.cxx new file mode 100644 index 000000000000..2754e5da0909 --- /dev/null +++ b/autodoc/source/parser_i/tokens/tkp2.cxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tkp2.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <tokens/tkp2.hxx> + +// NOT FULLY DECLARED SERVICES +#include <tools/tkpchars.hxx> +#include <tokens/tkpcont2.hxx> + +TokenParse2::TokenParse2() + : pChars(0) +{ +} + +void +TokenParse2::Start( CharacterSource & i_rSource ) +{ + pChars = &i_rSource; + SetStartContext(); +} + +bool +TokenParse2::GetNextToken() +{ + csv_assert(pChars != 0); + + bool bDone = false; + while ( NOT bDone AND NOT pChars->IsFinished() ) + { + CurrentContext().ReadCharChain(*pChars); + bDone = CurrentContext().PassNewToken(); + SetCurrentContext(CurrentContext().FollowUpContext()); + } + return bDone; +} + + diff --git a/autodoc/source/parser_i/tokens/tkpcont2.cxx b/autodoc/source/parser_i/tokens/tkpcont2.cxx new file mode 100644 index 000000000000..9fcb928bc7a4 --- /dev/null +++ b/autodoc/source/parser_i/tokens/tkpcont2.cxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tkpcont2.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <tokens/tkpcont2.hxx> + +// NOT FULLY DECLARED SERVICES + + + +TkpNullContex2 G_aNullContex2; + +TkpNullContex2 & +TkpContext_Null2_() +{ + return G_aNullContex2; +} + +TkpNullContex2::~TkpNullContex2() +{ +} + +void +TkpNullContex2::ReadCharChain( CharacterSource & ) +{ +} + +bool +TkpNullContex2::PassNewToken() +{ + return false; +} + +TkpContext & +TkpNullContex2::FollowUpContext() +{ + return *this; +} + + + diff --git a/autodoc/source/parser_i/tokens/tkpstam2.cxx b/autodoc/source/parser_i/tokens/tkpstam2.cxx new file mode 100644 index 000000000000..6a6d4a03b9c6 --- /dev/null +++ b/autodoc/source/parser_i/tokens/tkpstam2.cxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tkpstam2.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <tokens/tkpstam2.hxx> + +// NOT FULLY DECLARED SERVICES +#include <tokens/stmstar2.hxx> +#include <tools/tkpchars.hxx> + + +const intt C_nStatuslistResizeValue = 32; +const intt C_nTopStatus = 0; + +StateMachin2::StateMachin2( intt in_nStatusSize, + intt in_nInitial_StatusListSize ) + : pStati(new StmStatu2*[in_nInitial_StatusListSize]), + nCurrentStatus(C_nTopStatus), + nPeekedStatus(C_nTopStatus), + nStatusSize(in_nStatusSize), + nNrofStati(0), + nStatiSpace(in_nInitial_StatusListSize) +{ + csv_assert(in_nStatusSize > 0); + csv_assert(in_nInitial_StatusListSize > 0); + + memset(pStati, 0, sizeof(StmStatu2*) * nStatiSpace); +} + +intt +StateMachin2::AddStatus(StmStatu2 * let_dpStatus) +{ + if (nNrofStati == nStatiSpace) + { + ResizeStati(); + } + pStati[nNrofStati] = let_dpStatus; + return nNrofStati++; +} + +void +StateMachin2::AddToken( const char * in_sToken, + UINT16 in_nTokenId, + const INT16 * in_aBranches, + INT16 in_nBoundsStatus ) +{ + if (csv::no_str(in_sToken)) + return; + + // Durch existierende Stati durchhangeln: + nCurrentStatus = 0; + nPeekedStatus = 0; + + for ( const char * pChar = in_sToken; + *pChar != NULCH; + ++pChar ) + { + Peek(*pChar); + StmStatu2 & rPst = Status(nPeekedStatus); + if ( rPst.IsADefault() OR rPst.AsBounds() != 0 ) + { + nPeekedStatus = AddStatus( new StmArrayStatu2(nStatusSize, in_aBranches, 0, false ) ); + CurrentStatus().SetBranch( *pChar, nPeekedStatus ); + } + nCurrentStatus = nPeekedStatus; + } // end for + StmArrayStatu2 & rLastStatus = CurrentStatus(); + rLastStatus.SetTokenId(in_nTokenId); + for (intt i = 0; i < nStatusSize; i++) + { + if (Status(rLastStatus.NextBy(i)).AsBounds() != 0) + rLastStatus.SetBranch(i,in_nBoundsStatus); + } // end for +} + +StateMachin2::~StateMachin2() +{ + for (intt i = 0; i < nNrofStati; i++) + { + delete pStati[i]; + } + delete [] pStati; +} + +StmBoundsStatu2 & +StateMachin2::GetCharChain( UINT16 & o_nTokenId, + CharacterSource & io_rText ) +{ + nCurrentStatus = C_nTopStatus; + Peek(io_rText.CurChar()); + while (BoundsStatus() == 0) + { + nCurrentStatus = nPeekedStatus; + Peek(io_rText.MoveOn()); + } + o_nTokenId = CurrentStatus().TokenId(); + + return *BoundsStatus(); +} + +void +StateMachin2::ResizeStati() +{ + intt nNewSize = nStatiSpace + C_nStatuslistResizeValue; + intt i = 0; + StatusList pNewStati = new StmStatu2*[nNewSize]; + + for ( ; i < nNrofStati; i++) + { + pNewStati[i] = pStati[i]; + } + memset( pNewStati+i, + 0, + (nNewSize-i) * sizeof(StmStatu2*) ); + + delete [] pStati; + pStati = pNewStati; + nStatiSpace = nNewSize; +} + +StmStatu2 & +StateMachin2::Status(intt in_nStatusNr) const +{ + csv_assert( csv::in_range(intt(0), in_nStatusNr, intt(nNrofStati)) ); + return *pStati[in_nStatusNr]; +} + +StmArrayStatu2 & +StateMachin2::CurrentStatus() const +{ + StmArrayStatu2 * pCurSt = Status(nCurrentStatus).AsArray(); + if (pCurSt == 0) + { + csv_assert(false); + } + return *pCurSt; +} + +StmBoundsStatu2 * +StateMachin2::BoundsStatus() const +{ + return Status(nPeekedStatus).AsBounds(); +} + +void +StateMachin2::Peek(intt in_nBranch) +{ + StmArrayStatu2 & rSt = CurrentStatus(); + nPeekedStatus = rSt.NextBy(in_nBranch); +} diff --git a/autodoc/source/parser_i/tokens/x_parse2.cxx b/autodoc/source/parser_i/tokens/x_parse2.cxx new file mode 100644 index 000000000000..eadc8042f3a4 --- /dev/null +++ b/autodoc/source/parser_i/tokens/x_parse2.cxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: x_parse2.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <x_parse2.hxx> + +// NOT FULLY DECLARED SERVICES + + enum E_Type + { + x_Any = 0, + x_InvalidChar, + x_UnexpectedEOF + }; +void +X_AutodocParser::GetInfo( std::ostream & o_rOutputMedium ) const +{ + switch (eType) + { + case x_Any: + o_rOutputMedium << "Unspecified parsing exception ." << Endl(); + break; + case x_InvalidChar: + o_rOutputMedium << "Unknown character during parsing." << Endl(); + break; + case x_UnexpectedToken: + o_rOutputMedium << "Unexpected token " << sName << " found." << Endl(); + break; + case x_UnexpectedEOF: + o_rOutputMedium << "Unexpected end of file found." << Endl(); + break; + default: + o_rOutputMedium << "Unknown exception during parsing." << Endl(); + } +} + + |