1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <parser/unoidl.hxx>
24 // NOT FULLY DECLARED SERVICES
26 #include <cosv/file.hxx>
27 #include <ary/ary.hxx>
28 #include <ary/idl/i_gate.hxx>
29 #include <ary/doc/d_oldidldocu.hxx>
30 #include <../parser/inc/x_docu.hxx>
31 #include <parser/parserinfo.hxx>
32 #include <tools/filecoll.hxx>
33 #include <tools/tkpchars.hxx>
34 #include <s2_luidl/tkp_uidl.hxx>
35 #include <s2_luidl/distrib.hxx>
36 #include <s2_luidl/pe_file2.hxx>
37 #include <s2_dsapi/cx_dsapi.hxx>
38 #include <adc_msg.hxx>
39 #include <x_parse2.hxx>
47 class FileParsePerformers
53 ParserInfo
& io_rParserInfo
);
56 const char * i_sFullPath
);
59 CharacterSource aFileLoader
;
60 Dyn
<csi::uidl::TokenParser_Uidl
>
62 csi::uidl::TokenDistributor
64 Dyn
<csi::uidl::PE_File
>
65 pFileParseEnvironment
;
66 ParserInfo
& rParserInfo
;
70 IdlParser::IdlParser( ary::Repository
& io_rRepository
)
71 : pRepository(&io_rRepository
)
76 IdlParser::Run( const autodoc::FileCollector_Ifc
& i_rFiles
)
78 Dyn
<FileParsePerformers
>
80 new FileParsePerformers(*pRepository
,
81 static_cast< ParserInfo
& >(*this)) );
83 FileCollector::const_iterator iEnd
= i_rFiles
.End();
84 for ( FileCollector::const_iterator iter
= i_rFiles
.Begin();
88 Cout() << (*iter
) << " ..."<< Endl();
92 pFileParsePerformers
->ParseFile(*iter
);
94 catch (const X_AutodocParser
&)
97 TheMessages().Out_ParseError(CurFile(), CurLine());
99 = new FileParsePerformers(*pRepository
,
100 static_cast< ParserInfo
& >(*this));
104 // Currently thic catches only wrong since tags, while since tags are
105 // transformed. In this case the program shall be terminated.
106 Cerr() << xd
<< Endl();
111 Cout() << "Unknown error." << Endl();
113 // pFileParsePerformers = new FileParsePerformers( *pRepository );
118 FileParsePerformers::FileParsePerformers( ary::Repository
& io_rRepository
,
119 ParserInfo
& io_rParserInfo
)
121 aDistributor(io_rRepository
, io_rParserInfo
),
122 rParserInfo(io_rParserInfo
)
124 DYN
csi::dsapi::Context_Docu
*
126 = new csi::dsapi::Context_Docu( aDistributor
.DocuTokens_Receiver() );
127 pTokens
= new csi::uidl::TokenParser_Uidl( aDistributor
.CodeTokens_Receiver(), *dpDocuContext
);
128 pFileParseEnvironment
129 = new csi::uidl::PE_File(aDistributor
,rParserInfo
);
131 aDistributor
.SetTokenProvider(*pTokens
);
132 aDistributor
.SetTopParseEnvironment(*pFileParseEnvironment
);
136 FileParsePerformers::ParseFile( const char * i_sFullPath
)
138 csv::File
aFile(i_sFullPath
);
140 aFile
.open( csv::CFM_READ
);
141 csv_assert( aFile
.is_open() );
142 aFileLoader
.LoadText(aFile
);
145 rParserInfo
.Set_CurFile(i_sFullPath
, true); // true = count lines
146 pTokens
->Start(aFileLoader
);
147 aDistributor
.Reset();
150 aDistributor
.TradeToken();
151 } while ( NOT aFileLoader
.IsFinished() );
154 } // namespace autodoc
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */