xref: /trunk/main/autodoc/source/parser/cpp/preproc.hxx (revision 1c78a5d6)
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_CPP_PREPROC_HXX
25 #define ADC_CPP_PREPROC_HXX
26 
27 
28 
29 // USED SERVICES
30 	// BASE CLASSES
31 	// COMPONENTS
32 #include <deque>
33 	// PARAMETERS
34 
35 class CharacterSource;
36 
37 
38 namespace cpp
39 {
40 
41 class Token;
42 class CodeExplorer;
43 class DefineDescription;
44 
45 
46 class PreProcessor
47 {
48   public:
49     typedef std::map< String, DefineDescription* > MacroMap;
50 
51     // LIFECYCLE
52 						PreProcessor();
53 						~PreProcessor();
54     // OPERATONS
55     void                AssignPartners(
56                             CodeExplorer &      o_rCodeExplorer,
57                             CharacterSource &   o_rCharSource,
58                             const MacroMap &    i_rCurValidDefines );
59     void                Process_Token(
60                             cpp::Token &        let_drToken );
61     void                UnblockMacro(
62                             const char *        i_sMacroName );
63   private:
64     public: // Necessary for instantiation of static variable:
65     enum E_State
66     {
67         plain = 0,
68         expect_macro_bracket_left,
69         expect_macro_param,
70         state_MAX
71     };
72     typedef void (PreProcessor::*                   F_TOKENPROC )(cpp::Token &);
73     void                On_plain( cpp::Token & );
74     void                On_expect_macro_bracket_left( cpp::Token & );
75     void                On_expect_macro_param( cpp::Token & );
76 
77     private:  // Reprivate again:
78     typedef std::deque< DYN cpp::Token * >          TokenQueue;
79     typedef StringVector                  List_MacroParams;
80 
81 
82     bool                CheckForDefine(
83                             cpp::Token &        let_drToken );
84     void                InterpretMacro();
85 
86 	// DATA
87     static F_TOKENPROC  aTokProcs[state_MAX];
88         // Referenced extern objects
89     CodeExplorer *      pCppExplorer;
90     CharacterSource *   pSourceText;
91     const MacroMap *    pCurValidDefines;
92 
93         // internal data
94     TokenQueue          aTokens;
95 
96     E_State             eState;
97 
98     DefineDescription * pCurMacro;
99     DYN Token *         dpCurMacroName;
100     List_MacroParams    aCurMacroParams;
101     csv::StreamStr      aCurParamText;
102 
103     intt                nBracketInParameterCounter;
104     StringVector        aBlockedMacroNames;
105 };
106 
107 
108 
109 }   // end namespace cpp
110 
111 #endif
112 
113