178bc99aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
378bc99aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
478bc99aaSAndrew Rist * or more contributor license agreements. See the NOTICE file
578bc99aaSAndrew Rist * distributed with this work for additional information
678bc99aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file
778bc99aaSAndrew Rist * to you under the Apache License, Version 2.0 (the
878bc99aaSAndrew Rist * "License"); you may not use this file except in compliance
978bc99aaSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
1178bc99aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
1378bc99aaSAndrew Rist * Unless required by applicable law or agreed to in writing,
1478bc99aaSAndrew Rist * software distributed under the License is distributed on an
1578bc99aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1678bc99aaSAndrew Rist * KIND, either express or implied. See the License for the
1778bc99aaSAndrew Rist * specific language governing permissions and limitations
1878bc99aaSAndrew Rist * under the License.
19cdf0e10cSrcweir *
2078bc99aaSAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <parser/unoidl.hxx>
24cdf0e10cSrcweir
25cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
26cdf0e10cSrcweir #include <stdlib.h>
27cdf0e10cSrcweir #include <cosv/file.hxx>
28cdf0e10cSrcweir #include <ary/ary.hxx>
29cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
30cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
31cdf0e10cSrcweir #include <../parser/inc/x_docu.hxx>
32cdf0e10cSrcweir #include <parser/parserinfo.hxx>
33cdf0e10cSrcweir #include <tools/filecoll.hxx>
34cdf0e10cSrcweir #include <tools/tkpchars.hxx>
35cdf0e10cSrcweir #include <s2_luidl/tkp_uidl.hxx>
36cdf0e10cSrcweir #include <s2_luidl/distrib.hxx>
37cdf0e10cSrcweir #include <s2_luidl/pe_file2.hxx>
38cdf0e10cSrcweir #include <s2_dsapi/cx_dsapi.hxx>
39cdf0e10cSrcweir #include <adc_msg.hxx>
40cdf0e10cSrcweir #include <x_parse2.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir namespace autodoc
43cdf0e10cSrcweir {
44cdf0e10cSrcweir
45cdf0e10cSrcweir class FileParsePerformers
46cdf0e10cSrcweir {
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir FileParsePerformers(
49cdf0e10cSrcweir ary::Repository &
50cdf0e10cSrcweir io_rRepository,
51cdf0e10cSrcweir ParserInfo & io_rParserInfo );
52cdf0e10cSrcweir
53cdf0e10cSrcweir void ParseFile(
54cdf0e10cSrcweir const char * i_sFullPath );
55cdf0e10cSrcweir
56cdf0e10cSrcweir void ConnectLinks();
57cdf0e10cSrcweir
58cdf0e10cSrcweir private:
59cdf0e10cSrcweir CharacterSource aFileLoader;
60cdf0e10cSrcweir Dyn<csi::uidl::TokenParser_Uidl>
61cdf0e10cSrcweir pTokens;
62cdf0e10cSrcweir csi::uidl::TokenDistributor
63cdf0e10cSrcweir aDistributor;
64cdf0e10cSrcweir Dyn<csi::uidl::PE_File>
65cdf0e10cSrcweir pFileParseEnvironment;
66cdf0e10cSrcweir ary::Repository &
67cdf0e10cSrcweir rRepository;
68cdf0e10cSrcweir ParserInfo & rParserInfo;
69cdf0e10cSrcweir };
70cdf0e10cSrcweir
71cdf0e10cSrcweir
IdlParser(ary::Repository & io_rRepository)72cdf0e10cSrcweir IdlParser::IdlParser( ary::Repository & io_rRepository )
73cdf0e10cSrcweir : pRepository(&io_rRepository)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
77cdf0e10cSrcweir void
Run(const autodoc::FileCollector_Ifc & i_rFiles)78cdf0e10cSrcweir IdlParser::Run( const autodoc::FileCollector_Ifc & i_rFiles )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir Dyn<FileParsePerformers>
81cdf0e10cSrcweir pFileParsePerformers(
82cdf0e10cSrcweir new FileParsePerformers(*pRepository,
83cdf0e10cSrcweir static_cast< ParserInfo& >(*this)) );
84cdf0e10cSrcweir
85cdf0e10cSrcweir FileCollector::const_iterator iEnd = i_rFiles.End();
86cdf0e10cSrcweir for ( FileCollector::const_iterator iter = i_rFiles.Begin();
87cdf0e10cSrcweir iter != iEnd;
88cdf0e10cSrcweir ++iter )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir Cout() << (*iter) << " ..."<< Endl();
91cdf0e10cSrcweir
92cdf0e10cSrcweir try
93cdf0e10cSrcweir {
94cdf0e10cSrcweir pFileParsePerformers->ParseFile(*iter);
95cdf0e10cSrcweir }
96cdf0e10cSrcweir catch (X_AutodocParser &)
97cdf0e10cSrcweir {
98*ed731925Smseidel // Ignore and go on
99cdf0e10cSrcweir TheMessages().Out_ParseError(CurFile(), CurLine());
100cdf0e10cSrcweir pFileParsePerformers
101cdf0e10cSrcweir = new FileParsePerformers(*pRepository,
102cdf0e10cSrcweir static_cast< ParserInfo& >(*this));
103cdf0e10cSrcweir }
104cdf0e10cSrcweir catch (X_Docu & xd)
105cdf0e10cSrcweir {
106*ed731925Smseidel // Currently this catches only wrong since tags, while since tags are
107cdf0e10cSrcweir // transformed. In this case the program shall be terminated.
108cdf0e10cSrcweir Cerr() << xd << Endl();
109cdf0e10cSrcweir exit(1);
110cdf0e10cSrcweir }
111cdf0e10cSrcweir catch (...)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir Cout() << "Unknown error." << Endl();
114cdf0e10cSrcweir exit(0);
115cdf0e10cSrcweir // pFileParsePerformers = new FileParsePerformers( *pRepository );
116cdf0e10cSrcweir }
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir pFileParsePerformers->ConnectLinks();
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
FileParsePerformers(ary::Repository & io_rRepository,ParserInfo & io_rParserInfo)122cdf0e10cSrcweir FileParsePerformers::FileParsePerformers( ary::Repository & io_rRepository,
123cdf0e10cSrcweir ParserInfo & io_rParserInfo )
124cdf0e10cSrcweir : pTokens(0),
125cdf0e10cSrcweir aDistributor(io_rRepository, io_rParserInfo),
126cdf0e10cSrcweir rRepository( io_rRepository ),
127cdf0e10cSrcweir rParserInfo(io_rParserInfo)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir DYN csi::dsapi::Context_Docu *
130cdf0e10cSrcweir dpDocuContext
131cdf0e10cSrcweir = new csi::dsapi::Context_Docu( aDistributor.DocuTokens_Receiver() );
132cdf0e10cSrcweir pTokens = new csi::uidl::TokenParser_Uidl( aDistributor.CodeTokens_Receiver(), *dpDocuContext );
133cdf0e10cSrcweir pFileParseEnvironment
134cdf0e10cSrcweir = new csi::uidl::PE_File(aDistributor,rParserInfo);
135cdf0e10cSrcweir
136cdf0e10cSrcweir aDistributor.SetTokenProvider(*pTokens);
137cdf0e10cSrcweir aDistributor.SetTopParseEnvironment(*pFileParseEnvironment);
138cdf0e10cSrcweir }
139cdf0e10cSrcweir
140cdf0e10cSrcweir void
ParseFile(const char * i_sFullPath)141cdf0e10cSrcweir FileParsePerformers::ParseFile( const char * i_sFullPath )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir csv::File aFile(i_sFullPath);
144cdf0e10cSrcweir
145cdf0e10cSrcweir aFile.open( csv::CFM_READ );
146cdf0e10cSrcweir csv_assert( aFile.is_open() );
147cdf0e10cSrcweir aFileLoader.LoadText(aFile);
148cdf0e10cSrcweir aFile.close();
149cdf0e10cSrcweir
150cdf0e10cSrcweir rParserInfo.Set_CurFile(i_sFullPath, true); // true = count lines
151cdf0e10cSrcweir pTokens->Start(aFileLoader);
152cdf0e10cSrcweir aDistributor.Reset();
153cdf0e10cSrcweir
154cdf0e10cSrcweir do {
155cdf0e10cSrcweir aDistributor.TradeToken();
156cdf0e10cSrcweir } while ( NOT aFileLoader.IsFinished() );
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
159cdf0e10cSrcweir void
ConnectLinks()160cdf0e10cSrcweir FileParsePerformers::ConnectLinks()
161cdf0e10cSrcweir {
162cdf0e10cSrcweir // KORR_FUTURE ?
163cdf0e10cSrcweir // rRepository.RwGate_Idl().ConnectAdditionalLinks();
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
166cdf0e10cSrcweir } // namespace autodoc
167*ed731925Smseidel
168*ed731925Smseidel /* vim: set noet sw=4 ts=4: */
169