1*78bc99aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*78bc99aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*78bc99aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*78bc99aaSAndrew Rist  * distributed with this work for additional information
6*78bc99aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*78bc99aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*78bc99aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*78bc99aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*78bc99aaSAndrew Rist  *
11*78bc99aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*78bc99aaSAndrew Rist  *
13*78bc99aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*78bc99aaSAndrew Rist  * software distributed under the License is distributed on an
15*78bc99aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*78bc99aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*78bc99aaSAndrew Rist  * specific language governing permissions and limitations
18*78bc99aaSAndrew Rist  * under the License.
19*78bc99aaSAndrew Rist  *
20*78bc99aaSAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include "pe_tpltp.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
27cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir namespace cpp {
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
PE_TemplateTop(Cpp_PE * i_pParent)35cdf0e10cSrcweir PE_TemplateTop::PE_TemplateTop( Cpp_PE * i_pParent )
36cdf0e10cSrcweir 	:   Cpp_PE(i_pParent),
37cdf0e10cSrcweir         pStati( new PeStatusArray<PE_TemplateTop> ),
38cdf0e10cSrcweir         // aResult_Parameters,
39cdf0e10cSrcweir         bCurIsConstant(false)
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 		Setup_StatusFunctions();
42cdf0e10cSrcweir }
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 
~PE_TemplateTop()45cdf0e10cSrcweir PE_TemplateTop::~PE_TemplateTop()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir }
48cdf0e10cSrcweir 
49cdf0e10cSrcweir void
Call_Handler(const cpp::Token & i_rTok)50cdf0e10cSrcweir PE_TemplateTop::Call_Handler( const cpp::Token & i_rTok )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir void
Setup_StatusFunctions()56cdf0e10cSrcweir PE_TemplateTop::Setup_StatusFunctions()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	typedef CallFunction<PE_TemplateTop>::F_Tok	F_Tok;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	static F_Tok stateF_start[] =		    { &PE_TemplateTop::On_start_Less };
61cdf0e10cSrcweir 	static INT16 stateT_start[] =           { Tid_Less };
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	static F_Tok stateF_expect_qualifier[]= { &PE_TemplateTop::On_expect_qualifier_ClassOrTypename,
64cdf0e10cSrcweir 	                                          &PE_TemplateTop::On_expect_qualifier_Greater,
65cdf0e10cSrcweir 	                                          &PE_TemplateTop::On_expect_qualifier_ClassOrTypename };
66cdf0e10cSrcweir 	static INT16 stateT_expect_qualifier[]= { Tid_class,
67cdf0e10cSrcweir 	                                          Tid_Greater,
68cdf0e10cSrcweir 	                                          Tid_typename };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	static F_Tok stateF_expect_name[] =	    { &PE_TemplateTop::On_expect_name_Identifier };
71cdf0e10cSrcweir 	static INT16 stateT_expect_name[] =     { Tid_Identifier };
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	static F_Tok stateF_expect_separator[]=	{ &PE_TemplateTop::On_expect_separator_Comma,
74cdf0e10cSrcweir                                               &PE_TemplateTop::On_expect_separator_Greater };
75cdf0e10cSrcweir 	static INT16 stateT_expect_separator[]= { Tid_Comma,
76cdf0e10cSrcweir                                               Tid_Greater };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, start,            Hdl_SyntaxError);
79cdf0e10cSrcweir 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_qualifier, On_expect_qualifier_Other);
80cdf0e10cSrcweir 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_name,      Hdl_SyntaxError);
81cdf0e10cSrcweir 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_separator, Hdl_SyntaxError);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir void
InitData()85cdf0e10cSrcweir PE_TemplateTop::InitData()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir     pStati->SetCur(start);
88cdf0e10cSrcweir     csv::erase_container(aResult_Parameters);
89cdf0e10cSrcweir 	bCurIsConstant = false;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir void
TransferData()93cdf0e10cSrcweir PE_TemplateTop::TransferData()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir     pStati->SetCur(size_of_states);
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir void
Hdl_SyntaxError(const char * i_sText)99cdf0e10cSrcweir PE_TemplateTop::Hdl_SyntaxError(const char * i_sText)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     StdHandlingOfSyntaxError(i_sText);
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir void
On_start_Less(const char *)105cdf0e10cSrcweir PE_TemplateTop::On_start_Less( const char *)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir     SetTokenResult(done, stay);
108cdf0e10cSrcweir     pStati->SetCur(expect_qualifier);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir void
On_expect_qualifier_ClassOrTypename(const char *)112cdf0e10cSrcweir PE_TemplateTop::On_expect_qualifier_ClassOrTypename( const char *)
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     SetTokenResult(done, stay);
115cdf0e10cSrcweir     pStati->SetCur(expect_name);
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir void
On_expect_qualifier_Greater(const char *)119cdf0e10cSrcweir PE_TemplateTop::On_expect_qualifier_Greater(const char *)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     SetTokenResult(done, pop_success);
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir void
On_expect_qualifier_Other(const char *)125cdf0e10cSrcweir PE_TemplateTop::On_expect_qualifier_Other( const char *)
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     SetTokenResult(done, stay);
128cdf0e10cSrcweir     pStati->SetCur(expect_name);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     bCurIsConstant = true;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir void
On_expect_name_Identifier(const char * i_sText)134cdf0e10cSrcweir PE_TemplateTop::On_expect_name_Identifier( const char * i_sText)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     SetTokenResult(done, stay);
137cdf0e10cSrcweir     pStati->SetCur(expect_separator);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     StreamLock sl(50);
140cdf0e10cSrcweir     if ( NOT bCurIsConstant )
141cdf0e10cSrcweir     {
142cdf0e10cSrcweir         String sText( sl() << "typename " << i_sText << c_str );
143cdf0e10cSrcweir         aResult_Parameters.push_back(sText);
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir     else //
146cdf0e10cSrcweir     {
147cdf0e10cSrcweir         String sText( sl() << "constant " << i_sText << c_str );
148cdf0e10cSrcweir         aResult_Parameters.push_back(sText);
149cdf0e10cSrcweir         bCurIsConstant = false;
150cdf0e10cSrcweir     }  // endif
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir void
On_expect_separator_Comma(const char *)154cdf0e10cSrcweir PE_TemplateTop::On_expect_separator_Comma( const char *)
155cdf0e10cSrcweir {
156cdf0e10cSrcweir     SetTokenResult(done, stay);
157cdf0e10cSrcweir     pStati->SetCur(expect_qualifier);
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir void
On_expect_separator_Greater(const char *)161cdf0e10cSrcweir PE_TemplateTop::On_expect_separator_Greater( const char *)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir     SetTokenResult(done, pop_success);
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
169cdf0e10cSrcweir }   // namespace cpp
170