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_tydef.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
27cdf0e10cSrcweir #include <ary/cpp/c_gate.hxx>
28cdf0e10cSrcweir #include <ary/cpp/c_type.hxx>
29cdf0e10cSrcweir #include <ary/cpp/cp_ce.hxx>
30cdf0e10cSrcweir #include <all_toks.hxx>
31cdf0e10cSrcweir #include "pe_type.hxx"
32cdf0e10cSrcweir
33cdf0e10cSrcweir
34cdf0e10cSrcweir namespace cpp {
35cdf0e10cSrcweir
36cdf0e10cSrcweir
PE_Typedef(Cpp_PE * i_pParent)37cdf0e10cSrcweir PE_Typedef::PE_Typedef(Cpp_PE * i_pParent )
38cdf0e10cSrcweir : Cpp_PE(i_pParent),
39cdf0e10cSrcweir pStati( new PeStatusArray<PE_Typedef> ),
40cdf0e10cSrcweir // pSpType,
41cdf0e10cSrcweir // pSpuType,
42cdf0e10cSrcweir // sName
43cdf0e10cSrcweir nType(0)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir Setup_StatusFunctions();
46cdf0e10cSrcweir
47cdf0e10cSrcweir pSpType = new SP_Type(*this);
48cdf0e10cSrcweir pSpuType = new SPU_Type(*pSpType, 0, &PE_Typedef::SpReturn_Type);
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
~PE_Typedef()51cdf0e10cSrcweir PE_Typedef::~PE_Typedef()
52cdf0e10cSrcweir {
53cdf0e10cSrcweir }
54cdf0e10cSrcweir
55cdf0e10cSrcweir void
Call_Handler(const cpp::Token & i_rTok)56cdf0e10cSrcweir PE_Typedef::Call_Handler( const cpp::Token & i_rTok )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
61cdf0e10cSrcweir void
Setup_StatusFunctions()62cdf0e10cSrcweir PE_Typedef::Setup_StatusFunctions()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir typedef CallFunction<PE_Typedef>::F_Tok F_Tok;
65cdf0e10cSrcweir static F_Tok stateF_start[] = { &PE_Typedef::On_start_typedef };
66cdf0e10cSrcweir static INT16 stateT_start[] = { Tid_typedef };
67cdf0e10cSrcweir
68cdf0e10cSrcweir static F_Tok stateF_expectName[] = { &PE_Typedef::On_expectName_Identifier };
69cdf0e10cSrcweir static INT16 stateT_expectName[] = { Tid_Identifier };
70cdf0e10cSrcweir
71cdf0e10cSrcweir static F_Tok stateF_afterName[] = { &PE_Typedef::On_afterName_Semicolon };
72cdf0e10cSrcweir static INT16 stateT_afterName[] = { Tid_Semicolon };
73cdf0e10cSrcweir
74cdf0e10cSrcweir SEMPARSE_CREATE_STATUS(PE_Typedef, start, Hdl_SyntaxError);
75cdf0e10cSrcweir SEMPARSE_CREATE_STATUS(PE_Typedef, expectName, Hdl_SyntaxError);
76cdf0e10cSrcweir SEMPARSE_CREATE_STATUS(PE_Typedef, afterName, Hdl_SyntaxError);
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir void
InitData()80cdf0e10cSrcweir PE_Typedef::InitData()
81cdf0e10cSrcweir {
82cdf0e10cSrcweir pStati->SetCur(start);
83cdf0e10cSrcweir
84cdf0e10cSrcweir sName.clear();
85cdf0e10cSrcweir nType = 0;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir void
TransferData()89cdf0e10cSrcweir PE_Typedef::TransferData()
90cdf0e10cSrcweir {
91cdf0e10cSrcweir pStati->SetCur(size_of_states);
92cdf0e10cSrcweir
93cdf0e10cSrcweir ary::cpp::Typedef &
94cdf0e10cSrcweir rTypedef = Env().AryGate().Ces().Store_Typedef(
95cdf0e10cSrcweir Env().Context(), sName, nType );
96cdf0e10cSrcweir Env().Event_Store_Typedef(rTypedef);
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
99cdf0e10cSrcweir void
Hdl_SyntaxError(const char * i_sText)100cdf0e10cSrcweir PE_Typedef::Hdl_SyntaxError( const char * i_sText)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir StdHandlingOfSyntaxError(i_sText);
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir void
SpReturn_Type()106cdf0e10cSrcweir PE_Typedef::SpReturn_Type()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir pStati->SetCur(expectName);
109cdf0e10cSrcweir
110cdf0e10cSrcweir nType = pSpuType->Child().Result_Type().Id();
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113cdf0e10cSrcweir void
On_start_typedef(const char *)114cdf0e10cSrcweir PE_Typedef::On_start_typedef( const char * )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir pSpuType->Push(done);
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir void
On_expectName_Identifier(const char * i_sText)120cdf0e10cSrcweir PE_Typedef::On_expectName_Identifier( const char * i_sText )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir SetTokenResult(done, stay);
123cdf0e10cSrcweir pStati->SetCur(afterName);
124cdf0e10cSrcweir
125cdf0e10cSrcweir sName = i_sText;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir void
On_afterName_Semicolon(const char *)129cdf0e10cSrcweir PE_Typedef::On_afterName_Semicolon( const char * )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir SetTokenResult(done, pop_success);
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir } // namespace cpp
135cdf0e10cSrcweir
136cdf0e10cSrcweir
137cdf0e10cSrcweir
138