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