1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_namsp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include <pe_namsp.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <all_toks.hxx>
37 #include <ary/cpp/c_namesp.hxx>
38 #include <ary/cpp/c_gate.hxx>
39 #include <ary/cpp/cp_ce.hxx>
40 #include <semantic/callf.hxx>
41 #include "x_parse.hxx"
49 PE_Namespace::PE_Namespace( Cpp_PE
* i_pParent
)
51 pStati( new PeStatusArray
<PE_Namespace
> ),
55 Setup_StatusFunctions();
58 PE_Namespace::~PE_Namespace()
63 PE_Namespace::Setup_StatusFunctions()
65 typedef CallFunction
<PE_Namespace
>::F_Tok F_Tok
;
66 static F_Tok stateF_start
[] = { &PE_Namespace::On_start_Identifier
,
67 &PE_Namespace::On_start_SwBracket_Left
};
68 static INT16 stateT_start
[] = { Tid_Identifier
,
70 static F_Tok stateF_gotName
[] = { &PE_Namespace::On_gotName_SwBracket_Left
,
71 &PE_Namespace::On_gotName_Assign
};
72 static INT16 stateT_gotName
[] = { Tid_SwBracket_Left
,
74 static F_Tok stateF_expectSemicolon
[] = { &PE_Namespace::On_expectSemicolon_Semicolon
};
75 static INT16 stateT_expectSemicolon
[] = { Tid_Semicolon
};
77 SEMPARSE_CREATE_STATUS(PE_Namespace
, start
, Hdl_SyntaxError
);
78 SEMPARSE_CREATE_STATUS(PE_Namespace
, gotName
, Hdl_SyntaxError
);
79 SEMPARSE_CREATE_STATUS(PE_Namespace
, expectSemicolon
, Hdl_SyntaxError
);
83 PE_Namespace::Call_Handler( const cpp::Token
& i_rTok
)
85 pStati
->Cur().Call_Handler(i_rTok
.TypeId(), i_rTok
.Text());
89 PE_Namespace::InitData()
91 pStati
->SetCur(start
);
97 PE_Namespace::TransferData()
101 ary::cpp::Namespace
&
102 rNew
= Env().AryGate().Ces().CheckIn_Namespace(
105 Env().OpenNamespace(rNew
);
110 PE_Namespace::Hdl_SyntaxError( const char * i_sText
)
112 throw X_Parser( X_Parser::x_UnexpectedToken
,
113 i_sText
!= 0 ? i_sText
: "",
119 PE_Namespace::On_start_Identifier(const char * i_sText
)
121 SetTokenResult(done
, stay
);
122 pStati
->SetCur(gotName
);
124 sLocalName
= i_sText
;
128 PE_Namespace::On_start_SwBracket_Left(const char * )
130 SetTokenResult(done
, pop_success
);
131 pStati
->SetCur(size_of_states
);
133 sLocalName
= ""; // Anonymous namespace, a name is created in
134 // Gate().CheckIn_Namespace() .
140 PE_Namespace::On_gotName_SwBracket_Left(const char * )
142 SetTokenResult(done
, pop_success
);
143 pStati
->SetCur(size_of_states
);
149 PE_Namespace::On_gotName_Assign(const char * )
156 PE_Namespace::On_expectSemicolon_Semicolon(const char * )
158 SetTokenResult(done
,pop_success
);
159 pStati
->SetCur(size_of_states
);