1*1c78a5d6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*1c78a5d6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*1c78a5d6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*1c78a5d6SAndrew Rist * distributed with this work for additional information 6*1c78a5d6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*1c78a5d6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*1c78a5d6SAndrew Rist * "License"); you may not use this file except in compliance 9*1c78a5d6SAndrew Rist * with the License. You may obtain a copy of the License at 10*1c78a5d6SAndrew Rist * 11*1c78a5d6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*1c78a5d6SAndrew Rist * 13*1c78a5d6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*1c78a5d6SAndrew Rist * software distributed under the License is distributed on an 15*1c78a5d6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1c78a5d6SAndrew Rist * KIND, either express or implied. See the License for the 17*1c78a5d6SAndrew Rist * specific language governing permissions and limitations 18*1c78a5d6SAndrew Rist * under the License. 19*1c78a5d6SAndrew Rist * 20*1c78a5d6SAndrew Rist *************************************************************/ 21*1c78a5d6SAndrew Rist 22*1c78a5d6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef ADC_TKPCONTX_HXX 25cdf0e10cSrcweir #define ADC_TKPCONTX_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir // USED SERVICES 28cdf0e10cSrcweir // BASE CLASSES 29cdf0e10cSrcweir // COMPONENTS 30cdf0e10cSrcweir // PARAMETERS 31cdf0e10cSrcweir #include <tokens/token.hxx> 32cdf0e10cSrcweir class CharacterSource; 33cdf0e10cSrcweir class TkpNullContext; 34cdf0e10cSrcweir 35cdf0e10cSrcweir /** @task 36cdf0e10cSrcweir Specifies a context within which tokens are interpreted in a special 37cdf0e10cSrcweir way. For example in parsing C++ there could be a context for code, 38cdf0e10cSrcweir one for comments and a third one for preprocessor statements, because 39cdf0e10cSrcweir each of these would give the same token different meanings. 40cdf0e10cSrcweir 41cdf0e10cSrcweir The three functions 42cdf0e10cSrcweir ReadCharChain() 43cdf0e10cSrcweir PassNewToken() 44cdf0e10cSrcweir FollowUpContext() 45cdf0e10cSrcweir have to be called in this sequence. 46cdf0e10cSrcweir 47cdf0e10cSrcweir **/ 48cdf0e10cSrcweir class TkpContext 49cdf0e10cSrcweir { 50cdf0e10cSrcweir public: 51cdf0e10cSrcweir // LIFECYCLE ~TkpContext()52cdf0e10cSrcweir virtual ~TkpContext() {} 53cdf0e10cSrcweir 54cdf0e10cSrcweir // OPERATIONS 55cdf0e10cSrcweir /** @descr 56cdf0e10cSrcweir The functions starts to parse with the CurChar() of io_rText. 57cdf0e10cSrcweir It leaves io_rText.CurChar() at the first char of the following Token or 58cdf0e10cSrcweir the following Context. 59cdf0e10cSrcweir 60cdf0e10cSrcweir This function returns, when a context has parsed some characterss 61cdf0e10cSrcweir and completed a token OR left the context. 62cdf0e10cSrcweir If the token is to be ignored, it is cut from io_rText. 63cdf0e10cSrcweir 64cdf0e10cSrcweir If the token is to be parsed further in a different context, 65cdf0e10cSrcweir it is NOT cut from io_rText. 66cdf0e10cSrcweir 67cdf0e10cSrcweir After this function PassNewToken() has to be called. 68cdf0e10cSrcweir 69cdf0e10cSrcweir If the function has found a valid and complete token, PassNewToken() 70cdf0e10cSrcweir passes the parsed token to the internally known receiver and 71cdf0e10cSrcweir returns true. The token is cut from io_rText. 72cdf0e10cSrcweir **/ 73cdf0e10cSrcweir virtual void ReadCharChain( 74cdf0e10cSrcweir CharacterSource & io_rText ) = 0; 75cdf0e10cSrcweir /** Has to pass the parsed token to a known receiver. 76cdf0e10cSrcweir If the token is to be parsed further in a different context, 77cdf0e10cSrcweir PassNewToken() returns false, but the token is NOT cut from io_rText. 78cdf0e10cSrcweir 79cdf0e10cSrcweir @return true, if a token was passed. 80cdf0e10cSrcweir false, if the token was not parsed completely by this context 81cdf0e10cSrcweir or if the token is to be ignored. 82cdf0e10cSrcweir */ 83cdf0e10cSrcweir virtual bool PassNewToken() = 0; 84cdf0e10cSrcweir virtual TkpContext & 85cdf0e10cSrcweir FollowUpContext() = 0; 86cdf0e10cSrcweir 87cdf0e10cSrcweir static TkpNullContext & 88cdf0e10cSrcweir Null_(); 89cdf0e10cSrcweir }; 90cdf0e10cSrcweir 91cdf0e10cSrcweir class StateMachineContext 92cdf0e10cSrcweir { 93cdf0e10cSrcweir public: 94cdf0e10cSrcweir typedef TextToken::F_CRTOK F_CRTOK; 95cdf0e10cSrcweir ~StateMachineContext()96cdf0e10cSrcweir virtual ~StateMachineContext() {} 97cdf0e10cSrcweir 98cdf0e10cSrcweir /// Is used by StmBoundsStatus only. 99cdf0e10cSrcweir virtual void PerformStatusFunction( 100cdf0e10cSrcweir uintt i_nStatusSignal, 101cdf0e10cSrcweir F_CRTOK i_fTokenCreateFunction, 102cdf0e10cSrcweir CharacterSource & io_rText ) = 0; 103cdf0e10cSrcweir }; 104cdf0e10cSrcweir 105cdf0e10cSrcweir class TkpNullContext : public TkpContext 106cdf0e10cSrcweir { 107cdf0e10cSrcweir public: 108cdf0e10cSrcweir ~TkpNullContext(); 109cdf0e10cSrcweir 110cdf0e10cSrcweir virtual void ReadCharChain( 111cdf0e10cSrcweir CharacterSource & io_rText ); 112cdf0e10cSrcweir virtual bool PassNewToken(); 113cdf0e10cSrcweir virtual TkpContext & 114cdf0e10cSrcweir FollowUpContext(); 115cdf0e10cSrcweir }; 116cdf0e10cSrcweir 117cdf0e10cSrcweir namespace autodoc 118cdf0e10cSrcweir { 119cdf0e10cSrcweir 120cdf0e10cSrcweir class TkpDocuContext : public TkpContext 121cdf0e10cSrcweir { 122cdf0e10cSrcweir public: 123cdf0e10cSrcweir virtual void SetParentContext( 124cdf0e10cSrcweir TkpContext & io_rParentContext, 125cdf0e10cSrcweir const char * i_sMultiLineEndToken ) = 0; 126cdf0e10cSrcweir virtual void AssignDealer( 127cdf0e10cSrcweir TokenDealer & o_rDealer ) = 0; 128cdf0e10cSrcweir virtual void SetMode_IsMultiLine( 129cdf0e10cSrcweir bool i_bTrue ) = 0; 130cdf0e10cSrcweir }; 131cdf0e10cSrcweir 132cdf0e10cSrcweir } // namespace autodoc 133cdf0e10cSrcweir 134cdf0e10cSrcweir #endif 135cdf0e10cSrcweir 136cdf0e10cSrcweir 137