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 #include <precomp.h>
23 #include "pe_tpltp.hxx"
24 
25 
26 // NOT FULLY DECLARED SERVICES
27 #include <cosv/tpl/tpltools.hxx>
28 
29 
30 
31 namespace cpp {
32 
33 
34 
PE_TemplateTop(Cpp_PE * i_pParent)35 PE_TemplateTop::PE_TemplateTop( Cpp_PE * i_pParent )
36 	:   Cpp_PE(i_pParent),
37         pStati( new PeStatusArray<PE_TemplateTop> ),
38         // aResult_Parameters,
39         bCurIsConstant(false)
40 {
41 		Setup_StatusFunctions();
42 }
43 
44 
~PE_TemplateTop()45 PE_TemplateTop::~PE_TemplateTop()
46 {
47 }
48 
49 void
Call_Handler(const cpp::Token & i_rTok)50 PE_TemplateTop::Call_Handler( const cpp::Token & i_rTok )
51 {
52 	pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
53 }
54 
55 void
Setup_StatusFunctions()56 PE_TemplateTop::Setup_StatusFunctions()
57 {
58 	typedef CallFunction<PE_TemplateTop>::F_Tok	F_Tok;
59 
60 	static F_Tok stateF_start[] =		    { &PE_TemplateTop::On_start_Less };
61 	static INT16 stateT_start[] =           { Tid_Less };
62 
63 	static F_Tok stateF_expect_qualifier[]= { &PE_TemplateTop::On_expect_qualifier_ClassOrTypename,
64 	                                          &PE_TemplateTop::On_expect_qualifier_Greater,
65 	                                          &PE_TemplateTop::On_expect_qualifier_ClassOrTypename };
66 	static INT16 stateT_expect_qualifier[]= { Tid_class,
67 	                                          Tid_Greater,
68 	                                          Tid_typename };
69 
70 	static F_Tok stateF_expect_name[] =	    { &PE_TemplateTop::On_expect_name_Identifier };
71 	static INT16 stateT_expect_name[] =     { Tid_Identifier };
72 
73 	static F_Tok stateF_expect_separator[]=	{ &PE_TemplateTop::On_expect_separator_Comma,
74                                               &PE_TemplateTop::On_expect_separator_Greater };
75 	static INT16 stateT_expect_separator[]= { Tid_Comma,
76                                               Tid_Greater };
77 
78 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, start,            Hdl_SyntaxError);
79 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_qualifier, On_expect_qualifier_Other);
80 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_name,      Hdl_SyntaxError);
81 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_separator, Hdl_SyntaxError);
82 }
83 
84 void
InitData()85 PE_TemplateTop::InitData()
86 {
87     pStati->SetCur(start);
88     csv::erase_container(aResult_Parameters);
89 	bCurIsConstant = false;
90 }
91 
92 void
TransferData()93 PE_TemplateTop::TransferData()
94 {
95     pStati->SetCur(size_of_states);
96 }
97 
98 void
Hdl_SyntaxError(const char * i_sText)99 PE_TemplateTop::Hdl_SyntaxError(const char * i_sText)
100 {
101     StdHandlingOfSyntaxError(i_sText);
102 }
103 
104 void
On_start_Less(const char *)105 PE_TemplateTop::On_start_Less( const char *)
106 {
107     SetTokenResult(done, stay);
108     pStati->SetCur(expect_qualifier);
109 }
110 
111 void
On_expect_qualifier_ClassOrTypename(const char *)112 PE_TemplateTop::On_expect_qualifier_ClassOrTypename( const char *)
113 {
114     SetTokenResult(done, stay);
115     pStati->SetCur(expect_name);
116 }
117 
118 void
On_expect_qualifier_Greater(const char *)119 PE_TemplateTop::On_expect_qualifier_Greater(const char *)
120 {
121     SetTokenResult(done, pop_success);
122 }
123 
124 void
On_expect_qualifier_Other(const char *)125 PE_TemplateTop::On_expect_qualifier_Other( const char *)
126 {
127     SetTokenResult(done, stay);
128     pStati->SetCur(expect_name);
129 
130     bCurIsConstant = true;
131 }
132 
133 void
On_expect_name_Identifier(const char * i_sText)134 PE_TemplateTop::On_expect_name_Identifier( const char * i_sText)
135 {
136     SetTokenResult(done, stay);
137     pStati->SetCur(expect_separator);
138 
139     StreamLock sl(50);
140     if ( NOT bCurIsConstant )
141     {
142         String sText( sl() << "typename " << i_sText << c_str );
143         aResult_Parameters.push_back(sText);
144     }
145     else //
146     {
147         String sText( sl() << "constant " << i_sText << c_str );
148         aResult_Parameters.push_back(sText);
149         bCurIsConstant = false;
150     }  // endif
151 }
152 
153 void
On_expect_separator_Comma(const char *)154 PE_TemplateTop::On_expect_separator_Comma( const char *)
155 {
156     SetTokenResult(done, stay);
157     pStati->SetCur(expect_qualifier);
158 }
159 
160 void
On_expect_separator_Greater(const char *)161 PE_TemplateTop::On_expect_separator_Greater( const char *)
162 {
163     SetTokenResult(done, pop_success);
164 }
165 
166 
167 
168 
169 }   // namespace cpp
170