Update ooo320-m1
[ooovba.git] / autodoc / source / parser / cpp / pe_namsp.cxx
blobb73b5320e0a33d3442d201d900d7e888a6290d9f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_namsp.cxx,v $
10 * $Revision: 1.10 $
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 ************************************************************************/
31 #include <precomp.h>
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"
46 namespace cpp
49 PE_Namespace::PE_Namespace( Cpp_PE * i_pParent )
50 : Cpp_PE(i_pParent),
51 pStati( new PeStatusArray<PE_Namespace> ),
52 // sLocalname
53 bPush(false)
55 Setup_StatusFunctions();
58 PE_Namespace::~PE_Namespace()
62 void
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,
69 Tid_SwBracket_Left };
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,
73 Tid_Assign };
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);
82 void
83 PE_Namespace::Call_Handler( const cpp::Token & i_rTok )
85 pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
88 void
89 PE_Namespace::InitData()
91 pStati->SetCur(start);
92 sLocalName = "";
93 bPush = false;
96 void
97 PE_Namespace::TransferData()
99 if (bPush)
101 ary::cpp::Namespace &
102 rNew = Env().AryGate().Ces().CheckIn_Namespace(
103 Env().Context(),
104 sLocalName );
105 Env().OpenNamespace(rNew);
109 void
110 PE_Namespace::Hdl_SyntaxError( const char * i_sText)
112 throw X_Parser( X_Parser::x_UnexpectedToken,
113 i_sText != 0 ? i_sText : "",
114 Env().CurFileName(),
115 Env().LineCount() );
118 void
119 PE_Namespace::On_start_Identifier(const char * i_sText)
121 SetTokenResult(done, stay);
122 pStati->SetCur(gotName);
124 sLocalName = i_sText;
127 void
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() .
136 bPush = true;
139 void
140 PE_Namespace::On_gotName_SwBracket_Left(const char * )
142 SetTokenResult(done, pop_success);
143 pStati->SetCur(size_of_states);
145 bPush = true;
148 void
149 PE_Namespace::On_gotName_Assign(const char * )
151 // KORR_FUTURE
152 Hdl_SyntaxError(0);
155 void
156 PE_Namespace::On_expectSemicolon_Semicolon(const char * )
158 SetTokenResult(done,pop_success);
159 pStati->SetCur(size_of_states);
162 } // namespace cpp