xref: /AOO41X/main/autodoc/source/parser/inc/tokens/tkpcontx.hxx (revision 1c78a5d6c0093dece4c096ba53051800fbad6e33)
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_TKPCONTX_HXX
25 #define ADC_TKPCONTX_HXX
26 
27 // USED SERVICES
28     // BASE CLASSES
29     // COMPONENTS
30     // PARAMETERS
31 #include <tokens/token.hxx>
32 class CharacterSource;
33 class TkpNullContext;
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     The three functions
42             ReadCharChain()
43             PassNewToken()
44             FollowUpContext()
45     have to be called in this sequence.
46 
47 **/
48 class TkpContext
49 {
50   public:
51     // LIFECYCLE
~TkpContext()52     virtual                 ~TkpContext() {}
53 
54     // OPERATIONS
55     /** @descr
56         The functions starts to parse with the CurChar() of io_rText.
57         It leaves io_rText.CurChar() at the first char of the following Token or
58         the following Context.
59 
60         This function returns, when a context has parsed some characterss
61         and completed a token OR left the context.
62         If the token is to be ignored, it is cut from io_rText.
63 
64         If the token is to be parsed further in a different context,
65         it is NOT cut from io_rText.
66 
67         After this function PassNewToken() has to be called.
68 
69         If the function has found a valid and complete token, PassNewToken()
70         passes the parsed token to the internally known receiver and
71         returns true. The token is cut from io_rText.
72     **/
73     virtual void        ReadCharChain(
74                             CharacterSource &   io_rText ) = 0;
75     /** Has to pass the parsed token to a known receiver.
76         If the token is to be parsed further in a different context,
77         PassNewToken() returns false, but the token is NOT cut from io_rText.
78 
79         @return true, if a token was passed.
80                 false, if the token was not parsed completely by this context
81                        or if the token is to be ignored.
82     */
83     virtual bool        PassNewToken() = 0;
84     virtual TkpContext &
85                         FollowUpContext() = 0;
86 
87     static TkpNullContext &
88                         Null_();
89 };
90 
91 class StateMachineContext
92 {
93   public:
94     typedef TextToken::F_CRTOK F_CRTOK;
95 
~StateMachineContext()96     virtual ~StateMachineContext() {}
97 
98     /// Is used by StmBoundsStatus only.
99     virtual void        PerformStatusFunction(
100                             uintt               i_nStatusSignal,
101                             F_CRTOK             i_fTokenCreateFunction,
102                             CharacterSource &   io_rText ) = 0;
103 };
104 
105 class TkpNullContext : public TkpContext
106 {
107   public:
108                         ~TkpNullContext();
109 
110     virtual void        ReadCharChain(
111                             CharacterSource &   io_rText );
112     virtual bool        PassNewToken();
113     virtual TkpContext &
114                         FollowUpContext();
115 };
116 
117 namespace autodoc
118 {
119 
120 class TkpDocuContext : public TkpContext
121 {
122   public:
123     virtual void        SetParentContext(
124                             TkpContext &        io_rParentContext,
125                             const char *        i_sMultiLineEndToken ) = 0;
126     virtual void        AssignDealer(
127                             TokenDealer &       o_rDealer ) = 0;
128     virtual void        SetMode_IsMultiLine(
129                             bool                i_bTrue ) = 0;
130 };
131 
132 } // namespace autodoc
133 
134 #endif
135 
136 
137