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 <parser/unoidl.hxx>
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
27cdf0e10cSrcweir #include <stdlib.h>
28cdf0e10cSrcweir #include <cosv/file.hxx>
29cdf0e10cSrcweir #include <ary/ary.hxx>
30cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
31cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
32cdf0e10cSrcweir #include <../parser/inc/x_docu.hxx>
33cdf0e10cSrcweir #include <parser/parserinfo.hxx>
34cdf0e10cSrcweir #include <tools/filecoll.hxx>
35cdf0e10cSrcweir #include <tools/tkpchars.hxx>
36cdf0e10cSrcweir #include <s2_luidl/tkp_uidl.hxx>
37cdf0e10cSrcweir #include <s2_luidl/distrib.hxx>
38cdf0e10cSrcweir #include <s2_luidl/pe_file2.hxx>
39cdf0e10cSrcweir #include <s2_dsapi/cx_dsapi.hxx>
40cdf0e10cSrcweir #include <adc_msg.hxx>
41cdf0e10cSrcweir #include <x_parse2.hxx>
42cdf0e10cSrcweir
43cdf0e10cSrcweir
44cdf0e10cSrcweir
45cdf0e10cSrcweir namespace autodoc
46cdf0e10cSrcweir {
47cdf0e10cSrcweir
48cdf0e10cSrcweir
49cdf0e10cSrcweir class FileParsePerformers
50cdf0e10cSrcweir {
51cdf0e10cSrcweir public:
52cdf0e10cSrcweir FileParsePerformers(
53cdf0e10cSrcweir ary::Repository &
54cdf0e10cSrcweir io_rRepository,
55cdf0e10cSrcweir ParserInfo & io_rParserInfo );
56cdf0e10cSrcweir
57cdf0e10cSrcweir void ParseFile(
58cdf0e10cSrcweir const char * i_sFullPath );
59cdf0e10cSrcweir
60cdf0e10cSrcweir void ConnectLinks();
61cdf0e10cSrcweir
62cdf0e10cSrcweir private:
63cdf0e10cSrcweir CharacterSource aFileLoader;
64cdf0e10cSrcweir Dyn<csi::uidl::TokenParser_Uidl>
65cdf0e10cSrcweir pTokens;
66cdf0e10cSrcweir csi::uidl::TokenDistributor
67cdf0e10cSrcweir aDistributor;
68cdf0e10cSrcweir Dyn<csi::uidl::PE_File>
69cdf0e10cSrcweir pFileParseEnvironment;
70cdf0e10cSrcweir ary::Repository &
71cdf0e10cSrcweir rRepository;
72cdf0e10cSrcweir ParserInfo & rParserInfo;
73cdf0e10cSrcweir };
74cdf0e10cSrcweir
75cdf0e10cSrcweir
IdlParser(ary::Repository & io_rRepository)76cdf0e10cSrcweir IdlParser::IdlParser( ary::Repository & io_rRepository )
77cdf0e10cSrcweir : pRepository(&io_rRepository)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir void
Run(const autodoc::FileCollector_Ifc & i_rFiles)82cdf0e10cSrcweir IdlParser::Run( const autodoc::FileCollector_Ifc & i_rFiles )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir Dyn<FileParsePerformers>
85cdf0e10cSrcweir pFileParsePerformers(
86cdf0e10cSrcweir new FileParsePerformers(*pRepository,
87cdf0e10cSrcweir static_cast< ParserInfo& >(*this)) );
88cdf0e10cSrcweir
89cdf0e10cSrcweir FileCollector::const_iterator iEnd = i_rFiles.End();
90cdf0e10cSrcweir for ( FileCollector::const_iterator iter = i_rFiles.Begin();
91cdf0e10cSrcweir iter != iEnd;
92cdf0e10cSrcweir ++iter )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir Cout() << (*iter) << " ..."<< Endl();
95cdf0e10cSrcweir
96cdf0e10cSrcweir try
97cdf0e10cSrcweir {
98cdf0e10cSrcweir pFileParsePerformers->ParseFile(*iter);
99cdf0e10cSrcweir }
100cdf0e10cSrcweir catch (X_AutodocParser &)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir /// Ignore and goon
103cdf0e10cSrcweir TheMessages().Out_ParseError(CurFile(), CurLine());
104cdf0e10cSrcweir pFileParsePerformers
105cdf0e10cSrcweir = new FileParsePerformers(*pRepository,
106cdf0e10cSrcweir static_cast< ParserInfo& >(*this));
107cdf0e10cSrcweir }
108cdf0e10cSrcweir catch (X_Docu & xd)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir // Currently thic catches only wrong since tags, while since tags are
111cdf0e10cSrcweir // transformed. In this case the program shall be terminated.
112cdf0e10cSrcweir Cerr() << xd << Endl();
113cdf0e10cSrcweir exit(1);
114cdf0e10cSrcweir }
115cdf0e10cSrcweir catch (...)
116cdf0e10cSrcweir {
117cdf0e10cSrcweir Cout() << "Unknown error." << Endl();
118cdf0e10cSrcweir exit(0);
119cdf0e10cSrcweir // pFileParsePerformers = new FileParsePerformers( *pRepository );
120cdf0e10cSrcweir }
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
123cdf0e10cSrcweir pFileParsePerformers->ConnectLinks();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
FileParsePerformers(ary::Repository & io_rRepository,ParserInfo & io_rParserInfo)126cdf0e10cSrcweir FileParsePerformers::FileParsePerformers( ary::Repository & io_rRepository,
127cdf0e10cSrcweir ParserInfo & io_rParserInfo )
128cdf0e10cSrcweir : pTokens(0),
129cdf0e10cSrcweir aDistributor(io_rRepository, io_rParserInfo),
130cdf0e10cSrcweir rRepository( io_rRepository ),
131cdf0e10cSrcweir rParserInfo(io_rParserInfo)
132cdf0e10cSrcweir {
133cdf0e10cSrcweir DYN csi::dsapi::Context_Docu *
134cdf0e10cSrcweir dpDocuContext
135cdf0e10cSrcweir = new csi::dsapi::Context_Docu( aDistributor.DocuTokens_Receiver() );
136cdf0e10cSrcweir pTokens = new csi::uidl::TokenParser_Uidl( aDistributor.CodeTokens_Receiver(), *dpDocuContext );
137cdf0e10cSrcweir pFileParseEnvironment
138cdf0e10cSrcweir = new csi::uidl::PE_File(aDistributor,rParserInfo);
139cdf0e10cSrcweir
140cdf0e10cSrcweir aDistributor.SetTokenProvider(*pTokens);
141cdf0e10cSrcweir aDistributor.SetTopParseEnvironment(*pFileParseEnvironment);
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir void
ParseFile(const char * i_sFullPath)145cdf0e10cSrcweir FileParsePerformers::ParseFile( const char * i_sFullPath )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir csv::File aFile(i_sFullPath);
148cdf0e10cSrcweir
149cdf0e10cSrcweir aFile.open( csv::CFM_READ );
150cdf0e10cSrcweir csv_assert( aFile.is_open() );
151cdf0e10cSrcweir aFileLoader.LoadText(aFile);
152cdf0e10cSrcweir aFile.close();
153cdf0e10cSrcweir
154cdf0e10cSrcweir rParserInfo.Set_CurFile(i_sFullPath, true); // true = count lines
155cdf0e10cSrcweir pTokens->Start(aFileLoader);
156cdf0e10cSrcweir aDistributor.Reset();
157cdf0e10cSrcweir
158cdf0e10cSrcweir do {
159cdf0e10cSrcweir aDistributor.TradeToken();
160cdf0e10cSrcweir } while ( NOT aFileLoader.IsFinished() );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir void
ConnectLinks()164cdf0e10cSrcweir FileParsePerformers::ConnectLinks()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir // KORR_FUTURE ?
167cdf0e10cSrcweir // rRepository.RwGate_Idl().ConnectAdditionalLinks();
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir } // namespace autodoc
171