diff options
Diffstat (limited to 'autodoc/source/parser/tokens')
-rw-r--r-- | autodoc/source/parser/tokens/makefile.mk | 62 | ||||
-rw-r--r-- | autodoc/source/parser/tokens/stmstarr.cxx | 99 | ||||
-rw-r--r-- | autodoc/source/parser/tokens/stmstate.cxx | 46 | ||||
-rw-r--r-- | autodoc/source/parser/tokens/stmstfin.cxx | 61 | ||||
-rw-r--r-- | autodoc/source/parser/tokens/tkp.cxx | 72 | ||||
-rw-r--r-- | autodoc/source/parser/tokens/tkpcontx.cxx | 68 | ||||
-rw-r--r-- | autodoc/source/parser/tokens/tkpstama.cxx | 177 | ||||
-rw-r--r-- | autodoc/source/parser/tokens/tokdeal.cxx | 50 |
8 files changed, 635 insertions, 0 deletions
diff --git a/autodoc/source/parser/tokens/makefile.mk b/autodoc/source/parser/tokens/makefile.mk new file mode 100644 index 000000000000..beb3207154fb --- /dev/null +++ b/autodoc/source/parser/tokens/makefile.mk @@ -0,0 +1,62 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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=parser_tokens +TARGETTYPE=CUI + + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true +PRJINC=$(PRJ)$/source + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/source$/mkinc$/fullcpp.mk + + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/stmstarr.obj \ + $(OBJ)$/stmstate.obj \ + $(OBJ)$/stmstfin.obj \ + $(OBJ)$/tkpstama.obj \ + $(OBJ)$/tkp.obj \ + $(OBJ)$/tkpcontx.obj \ + $(OBJ)$/tokdeal.obj + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/autodoc/source/parser/tokens/stmstarr.cxx b/autodoc/source/parser/tokens/stmstarr.cxx new file mode 100644 index 000000000000..e029b3c11f45 --- /dev/null +++ b/autodoc/source/parser/tokens/stmstarr.cxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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/stmstarr.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <x_parse.hxx> + + + +StmArrayStatus::StmArrayStatus( intt i_nStatusSize, + const INT16 * in_aArrayModel, + F_CRTOK i_fTokenCreateFunction, + bool in_bIsDefault ) + : dpBranches(new StmStatus::Branch[i_nStatusSize]), + nNrOfBranches(i_nStatusSize), + fTokenCreateFunction(i_fTokenCreateFunction), + bIsADefault(in_bIsDefault) +{ + 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 +} + +StmArrayStatus::~StmArrayStatus() +{ + delete [] dpBranches; +} + +bool +StmArrayStatus::SetBranch( intt in_nBranchIx, + StmStatus::Branch in_nBranch ) +{ + if ( csv::in_range(intt(0), in_nBranchIx, intt(nNrOfBranches) ) ) + { + dpBranches[in_nBranchIx] = in_nBranch; + return true; + } + return false; +} + + +StmStatus::Branch +StmArrayStatus::NextBy(intt in_nIndex) const +{ + if (in_nIndex < 0) + throw X_Parser(X_Parser::x_InvalidChar, "", String::Null_(), 0); + + return in_nIndex < nNrOfBranches + ? dpBranches[in_nIndex] + : dpBranches[nNrOfBranches - 1]; +} + + +bool +StmArrayStatus::IsADefault() const +{ + return bIsADefault; +} + +StmArrayStatus * +StmArrayStatus::AsArray() +{ + return this; +} + diff --git a/autodoc/source/parser/tokens/stmstate.cxx b/autodoc/source/parser/tokens/stmstate.cxx new file mode 100644 index 000000000000..991cad13cb85 --- /dev/null +++ b/autodoc/source/parser/tokens/stmstate.cxx @@ -0,0 +1,46 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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/stmstate.hxx> + + +// NOT FULLY DECLARED SERVICES + +StmArrayStatus * +StmStatus::AsArray() +{ + return 0; +} + +StmBoundsStatus * +StmStatus::AsBounds() +{ + return 0; +} + + diff --git a/autodoc/source/parser/tokens/stmstfin.cxx b/autodoc/source/parser/tokens/stmstfin.cxx new file mode 100644 index 000000000000..c6999e596e58 --- /dev/null +++ b/autodoc/source/parser/tokens/stmstfin.cxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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/stmstfin.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <tokens/tkpcontx.hxx> + + +StmBoundsStatus::StmBoundsStatus( 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 +StmBoundsStatus::IsADefault() const +{ + return bIsDefault; +} + +StmBoundsStatus * +StmBoundsStatus::AsBounds() +{ + return this; +} + + + diff --git a/autodoc/source/parser/tokens/tkp.cxx b/autodoc/source/parser/tokens/tkp.cxx new file mode 100644 index 000000000000..900fdccefd43 --- /dev/null +++ b/autodoc/source/parser/tokens/tkp.cxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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/tkp.hxx> + +// NOT FULLY DECLARED SERVICES +#include <tools/tkpchars.hxx> +#include <tokens/tkpcontx.hxx> + + + +TokenParser::TokenParser() + : pChars(0), + bHasMore(false) +{ +} + +void +TokenParser::Start( CharacterSource & i_rSource ) +{ + InitSource(i_rSource); +} + +void +TokenParser::GetNextToken() +{ + csv_assert(pChars != 0); + + bHasMore = NOT pChars->IsFinished(); + + for ( bool bDone = NOT bHasMore; NOT bDone; ) + { + CurrentContext().ReadCharChain(*pChars); + bDone = CurrentContext().PassNewToken(); + SetCurrentContext(CurrentContext().FollowUpContext()); + } +} + +void +TokenParser::InitSource( CharacterSource & i_rSource ) +{ + pChars = &i_rSource; + bHasMore = true; + SetStartContext(); +} + + diff --git a/autodoc/source/parser/tokens/tkpcontx.cxx b/autodoc/source/parser/tokens/tkpcontx.cxx new file mode 100644 index 000000000000..cbaab756c038 --- /dev/null +++ b/autodoc/source/parser/tokens/tkpcontx.cxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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/tkpcontx.hxx> + +// NOT FULLY DECLARED SERVICES + + + +TkpNullContext G_aNullContext; + +TkpNullContext & +TkpContext::Null_() +{ + return G_aNullContext; +} + +TkpNullContext::~TkpNullContext() +{ +} + +void +TkpNullContext::ReadCharChain( CharacterSource & ) +{ +} + +bool +TkpNullContext::PassNewToken() +{ + return false; +} + +TkpContext & +TkpNullContext::FollowUpContext() +{ + return *this; +} + + + + + + diff --git a/autodoc/source/parser/tokens/tkpstama.cxx b/autodoc/source/parser/tokens/tkpstama.cxx new file mode 100644 index 000000000000..9cf964601798 --- /dev/null +++ b/autodoc/source/parser/tokens/tkpstama.cxx @@ -0,0 +1,177 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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/tkpstama.hxx> + +// NOT FULLY DECLARED SERVICES +// #include <srcfind.hxx> +#include <tokens/stmstarr.hxx> +//#include <parseinc.hxx> +#include <tools/tkpchars.hxx> + + +const intt C_nStatuslistResizeValue = 32; +const intt C_nTopStatus = 0; + +StateMachine::StateMachine( intt in_nStatusSize, + intt in_nInitial_StatusListSize ) + : pStati(new StmStatus*[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(StmStatus*) * nStatiSpace); +} + +intt +StateMachine::AddStatus(StmStatus * let_dpStatus) +{ + if (nNrofStati == nStatiSpace) + { + ResizeStati(); + } + pStati[nNrofStati] = let_dpStatus; + return nNrofStati++; +} + +void +StateMachine::AddToken( const char * in_sToken, + TextToken::F_CRTOK in_fTokenCreateFunction, + 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); + StmStatus & rPst = Status(nPeekedStatus); + if ( rPst.IsADefault() OR rPst.AsBounds() != 0 ) + { + nPeekedStatus = AddStatus( new StmArrayStatus(nStatusSize, in_aBranches, 0, false ) ); + CurrentStatus().SetBranch( *pChar, nPeekedStatus ); + } + nCurrentStatus = nPeekedStatus; + } // end for + StmArrayStatus & rLastStatus = CurrentStatus(); + rLastStatus.SetTokenCreateFunction(in_fTokenCreateFunction); + for (intt i = 0; i < nStatusSize; i++) + { + if (Status(rLastStatus.NextBy(i)).AsBounds() != 0) + rLastStatus.SetBranch(i,in_nBoundsStatus); + } // end for +} + +StateMachine::~StateMachine() +{ + for (intt i = 0; i < nNrofStati; i++) + { + delete pStati[i]; + } + delete [] pStati; +} + +StmBoundsStatus & +StateMachine::GetCharChain( TextToken::F_CRTOK & o_nTokenCreateFunction, + CharacterSource & io_rText ) +{ + nCurrentStatus = C_nTopStatus; + + Peek(io_rText.CurChar()); + while (BoundsStatus() == 0) + { + nCurrentStatus = nPeekedStatus; + Peek(io_rText.MoveOn()); + } + o_nTokenCreateFunction = CurrentStatus().TokenCreateFunction(); + + return *BoundsStatus(); +} + +void +StateMachine::ResizeStati() +{ + intt nNewSize = nStatiSpace + C_nStatuslistResizeValue; + intt i = 0; + StatusList pNewStati = new StmStatus*[nNewSize]; + + for ( ; i < nNrofStati; i++) + { + pNewStati[i] = pStati[i]; + } + memset( pNewStati+i, + 0, + (nNewSize-i) * sizeof(StmStatus*) ); + + delete [] pStati; + pStati = pNewStati; + nStatiSpace = nNewSize; +} + +StmStatus & +StateMachine::Status(intt in_nStatusNr) const +{ + csv_assert( csv::in_range(intt(0), in_nStatusNr, intt(nNrofStati)) ); + return *pStati[in_nStatusNr]; +} + +StmArrayStatus & +StateMachine::CurrentStatus() const +{ + StmArrayStatus * pCurSt = Status(nCurrentStatus).AsArray(); + + csv_assert(pCurSt != 0); +// if(pCurSt == 0) +// csv_assert(false); + return *pCurSt; +} + +StmBoundsStatus * +StateMachine::BoundsStatus() const +{ + return Status(nPeekedStatus).AsBounds(); +} + +void +StateMachine::Peek(intt in_nBranch) +{ + StmArrayStatus & rSt = CurrentStatus(); + nPeekedStatus = rSt.NextBy(in_nBranch); +} diff --git a/autodoc/source/parser/tokens/tokdeal.cxx b/autodoc/source/parser/tokens/tokdeal.cxx new file mode 100644 index 000000000000..4f4273b36aba --- /dev/null +++ b/autodoc/source/parser/tokens/tokdeal.cxx @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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/tokdeal.hxx> +#include <tokens/token.hxx> + + +// NOT FULLY DEFINED SERVICES + + + +void +Tok_Eof::DealOut( TokenDealer & o_rDealer ) +{ + o_rDealer.Deal_Eof(); +}; + +const char * +Tok_Eof::Text() const +{ + return ""; +} + + + |