xref: /trunk/main/autodoc/source/parser/cpp/pe_namsp.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_namsp.hxx>
30 
31 
32 // NOT FULLY DECLARED SERVICES
33 #include <all_toks.hxx>
34 #include <ary/cpp/c_namesp.hxx>
35 #include <ary/cpp/c_gate.hxx>
36 #include <ary/cpp/cp_ce.hxx>
37 #include <semantic/callf.hxx>
38 #include "x_parse.hxx"
39 
40 
41 
42 
43 namespace cpp
44 {
45 
46 PE_Namespace::PE_Namespace( Cpp_PE * i_pParent )
47     :   Cpp_PE(i_pParent),
48         pStati( new PeStatusArray<PE_Namespace> ),
49         // sLocalname
50         bPush(false)
51 {
52     Setup_StatusFunctions();
53 }
54 
55 PE_Namespace::~PE_Namespace()
56 {
57 }
58 
59 void
60 PE_Namespace::Setup_StatusFunctions()
61 {
62     typedef CallFunction<PE_Namespace>::F_Tok   F_Tok;
63     static F_Tok stateF_start[] =           { &PE_Namespace::On_start_Identifier,
64                                               &PE_Namespace::On_start_SwBracket_Left };
65     static INT16 stateT_start[] =           { Tid_Identifier,
66                                               Tid_SwBracket_Left };
67     static F_Tok stateF_gotName[] =         { &PE_Namespace::On_gotName_SwBracket_Left,
68                                               &PE_Namespace::On_gotName_Assign };
69     static INT16 stateT_gotName[] =         { Tid_SwBracket_Left,
70                                               Tid_Assign };
71     static F_Tok stateF_expectSemicolon[] = { &PE_Namespace::On_expectSemicolon_Semicolon };
72     static INT16 stateT_expectSemicolon[] = { Tid_Semicolon };
73 
74     SEMPARSE_CREATE_STATUS(PE_Namespace, start, Hdl_SyntaxError);
75     SEMPARSE_CREATE_STATUS(PE_Namespace, gotName, Hdl_SyntaxError);
76     SEMPARSE_CREATE_STATUS(PE_Namespace, expectSemicolon, Hdl_SyntaxError);
77 }
78 
79 void
80 PE_Namespace::Call_Handler( const cpp::Token &  i_rTok )
81 {
82     pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
83 }
84 
85 void
86 PE_Namespace::InitData()
87 {
88     pStati->SetCur(start);
89     sLocalName = "";
90     bPush = false;
91 }
92 
93 void
94 PE_Namespace::TransferData()
95 {
96     if (bPush)
97     {
98         ary::cpp::Namespace &
99             rNew = Env().AryGate().Ces().CheckIn_Namespace(
100                                              Env().Context(),
101                                              sLocalName );
102         Env().OpenNamespace(rNew);
103     }
104 }
105 
106 void
107 PE_Namespace::Hdl_SyntaxError( const char * i_sText)
108 {
109     throw X_Parser( X_Parser::x_UnexpectedToken,
110                     i_sText != 0 ? i_sText : "",
111                     Env().CurFileName(),
112                     Env().LineCount() );
113 }
114 
115 void
116 PE_Namespace::On_start_Identifier(const char * i_sText)
117 {
118     SetTokenResult(done, stay);
119     pStati->SetCur(gotName);
120 
121     sLocalName = i_sText;
122 }
123 
124 void
125 PE_Namespace::On_start_SwBracket_Left(const char * )
126 {
127     SetTokenResult(done, pop_success);
128     pStati->SetCur(size_of_states);
129 
130     sLocalName = "";    // Anonymous namespace, a name is created in
131                         //   Gate().CheckIn_Namespace() .
132 
133     bPush = true;
134 }
135 
136 void
137 PE_Namespace::On_gotName_SwBracket_Left(const char * )
138 {
139     SetTokenResult(done, pop_success);
140     pStati->SetCur(size_of_states);
141 
142     bPush = true;
143 }
144 
145 void
146 PE_Namespace::On_gotName_Assign(const char * )
147 {
148     // KORR_FUTURE
149     Hdl_SyntaxError(0);
150 }
151 
152 void
153 PE_Namespace::On_expectSemicolon_Semicolon(const char * )
154 {
155     SetTokenResult(done,pop_success);
156     pStati->SetCur(size_of_states);
157 }
158 
159 }   // namespace cpp
160 
161 
162 
163 
164