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_TKP_HXX
25 #define ADC_TKP_HXX
26 
27 // USED SERVICES
28 	// BASE CLASSES
29 	// COMPONENTS
30 class CharacterSource;
31 class TkpContext;
32 	// PARAMETRS
33 
34 
35 
36 /** This is the interface for parser classes, which get a sequence of tokens from
37 	a text.
38 
39 	Start() starts to parse the text from the given i_rSource.
40 	GetNextToken() returns a Token on the heap as long as there are
41 	still characters in the text left. This can be checked by
42     HasMore().
43 
44 	The algorithms for parsing tokens from the text are an issue of
45 	the derived classes.
46 */
47 #if 0
48 /**
49     Parsing can be interrupted for a different source by PushSource().
50     The parsing before interruption is continued after PopSource().
51 */
52 #endif // 0
53 
54 class TokenParser
55 {
56   public:
57 	// LIFECYCLE
58 						TokenParser();
~TokenParser()59 	virtual				~TokenParser() {}
60 
61 	// OPERATIONS
62     /** Start parsing a character source. Any previously parsed sources
63         are discarded.
64     */
65 	virtual void   		Start(
66 							CharacterSource &
67 											i_rSource );
68 
69 	/** @short	Gets the next identifiable token out of the
70 		source code.
71 	*/
72 	void				GetNextToken();
73 
74     /// @return true, if there are more tokens to parse.
HasMore() const75 	bool				HasMore() const			{ return bHasMore; }
76 
77   private:
78     void                InitSource(
79 							CharacterSource &
80 											i_rSource );
81 
82 	virtual void		SetStartContext() = 0;
83 	virtual void        SetCurrentContext(
84 							TkpContext &		io_rContext ) = 0;
85 	virtual TkpContext &
86 						CurrentContext() = 0;
87 	// DATA
88 	CharacterSource *	pChars;
89 	bool				bHasMore;
90 };
91 
92 
93 #endif
94 
95 
96