1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "pe_tpltp.hxx"
30 
31 
32 // NOT FULLY DECLARED SERVICES
33 #include <cosv/tpl/tpltools.hxx>
34 
35 
36 
37 namespace cpp {
38 
39 
40 
41 PE_TemplateTop::PE_TemplateTop( Cpp_PE * i_pParent )
42 	:   Cpp_PE(i_pParent),
43         pStati( new PeStatusArray<PE_TemplateTop> ),
44         // aResult_Parameters,
45         bCurIsConstant(false)
46 {
47 		Setup_StatusFunctions();
48 }
49 
50 
51 PE_TemplateTop::~PE_TemplateTop()
52 {
53 }
54 
55 void
56 PE_TemplateTop::Call_Handler( const cpp::Token & i_rTok )
57 {
58 	pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
59 }
60 
61 void
62 PE_TemplateTop::Setup_StatusFunctions()
63 {
64 	typedef CallFunction<PE_TemplateTop>::F_Tok	F_Tok;
65 
66 	static F_Tok stateF_start[] =		    { &PE_TemplateTop::On_start_Less };
67 	static INT16 stateT_start[] =           { Tid_Less };
68 
69 	static F_Tok stateF_expect_qualifier[]= { &PE_TemplateTop::On_expect_qualifier_ClassOrTypename,
70 	                                          &PE_TemplateTop::On_expect_qualifier_Greater,
71 	                                          &PE_TemplateTop::On_expect_qualifier_ClassOrTypename };
72 	static INT16 stateT_expect_qualifier[]= { Tid_class,
73 	                                          Tid_Greater,
74 	                                          Tid_typename };
75 
76 	static F_Tok stateF_expect_name[] =	    { &PE_TemplateTop::On_expect_name_Identifier };
77 	static INT16 stateT_expect_name[] =     { Tid_Identifier };
78 
79 	static F_Tok stateF_expect_separator[]=	{ &PE_TemplateTop::On_expect_separator_Comma,
80                                               &PE_TemplateTop::On_expect_separator_Greater };
81 	static INT16 stateT_expect_separator[]= { Tid_Comma,
82                                               Tid_Greater };
83 
84 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, start,            Hdl_SyntaxError);
85 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_qualifier, On_expect_qualifier_Other);
86 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_name,      Hdl_SyntaxError);
87 	SEMPARSE_CREATE_STATUS(PE_TemplateTop, expect_separator, Hdl_SyntaxError);
88 }
89 
90 void
91 PE_TemplateTop::InitData()
92 {
93     pStati->SetCur(start);
94     csv::erase_container(aResult_Parameters);
95 	bCurIsConstant = false;
96 }
97 
98 void
99 PE_TemplateTop::TransferData()
100 {
101     pStati->SetCur(size_of_states);
102 }
103 
104 void
105 PE_TemplateTop::Hdl_SyntaxError(const char * i_sText)
106 {
107     StdHandlingOfSyntaxError(i_sText);
108 }
109 
110 void
111 PE_TemplateTop::On_start_Less( const char *)
112 {
113     SetTokenResult(done, stay);
114     pStati->SetCur(expect_qualifier);
115 }
116 
117 void
118 PE_TemplateTop::On_expect_qualifier_ClassOrTypename( const char *)
119 {
120     SetTokenResult(done, stay);
121     pStati->SetCur(expect_name);
122 }
123 
124 void
125 PE_TemplateTop::On_expect_qualifier_Greater(const char *)
126 {
127     SetTokenResult(done, pop_success);
128 }
129 
130 void
131 PE_TemplateTop::On_expect_qualifier_Other( const char *)
132 {
133     SetTokenResult(done, stay);
134     pStati->SetCur(expect_name);
135 
136     bCurIsConstant = true;
137 }
138 
139 void
140 PE_TemplateTop::On_expect_name_Identifier( const char * i_sText)
141 {
142     SetTokenResult(done, stay);
143     pStati->SetCur(expect_separator);
144 
145     StreamLock sl(50);
146     if ( NOT bCurIsConstant )
147     {
148         String sText( sl() << "typename " << i_sText << c_str );
149         aResult_Parameters.push_back(sText);
150     }
151     else //
152     {
153         String sText( sl() << "constant " << i_sText << c_str );
154         aResult_Parameters.push_back(sText);
155         bCurIsConstant = false;
156     }  // endif
157 }
158 
159 void
160 PE_TemplateTop::On_expect_separator_Comma( const char *)
161 {
162     SetTokenResult(done, stay);
163     pStati->SetCur(expect_qualifier);
164 }
165 
166 void
167 PE_TemplateTop::On_expect_separator_Greater( const char *)
168 {
169     SetTokenResult(done, pop_success);
170 }
171 
172 
173 
174 
175 }   // namespace cpp
176