1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <parser/unoidl.hxx>
33 // NOT FULLY DECLARED SERVICES
35 #include <cosv/file.hxx>
36 #include <ary/ary.hxx>
37 #include <ary/idl/i_gate.hxx>
38 #include <ary/doc/d_oldidldocu.hxx>
39 #include <../parser/inc/x_docu.hxx>
40 #include <parser/parserinfo.hxx>
41 #include <tools/filecoll.hxx>
42 #include <tools/tkpchars.hxx>
43 #include <s2_luidl/tkp_uidl.hxx>
44 #include <s2_luidl/distrib.hxx>
45 #include <s2_luidl/pe_file2.hxx>
46 #include <s2_dsapi/cx_dsapi.hxx>
47 #include <adc_msg.hxx>
48 #include <x_parse2.hxx>
56 class FileParsePerformers
62 ParserInfo
& io_rParserInfo
);
65 const char * i_sFullPath
);
68 CharacterSource aFileLoader
;
69 Dyn
<csi::uidl::TokenParser_Uidl
>
71 csi::uidl::TokenDistributor
73 Dyn
<csi::uidl::PE_File
>
74 pFileParseEnvironment
;
77 ParserInfo
& rParserInfo
;
81 IdlParser::IdlParser( ary::Repository
& io_rRepository
)
82 : pRepository(&io_rRepository
)
87 IdlParser::Run( const autodoc::FileCollector_Ifc
& i_rFiles
)
89 Dyn
<FileParsePerformers
>
91 new FileParsePerformers(*pRepository
,
92 static_cast< ParserInfo
& >(*this)) );
94 FileCollector::const_iterator iEnd
= i_rFiles
.End();
95 for ( FileCollector::const_iterator iter
= i_rFiles
.Begin();
99 Cout() << (*iter
) << " ..."<< Endl();
103 pFileParsePerformers
->ParseFile(*iter
);
105 catch (const X_AutodocParser
&)
108 TheMessages().Out_ParseError(CurFile(), CurLine());
110 = new FileParsePerformers(*pRepository
,
111 static_cast< ParserInfo
& >(*this));
115 // Currently thic catches only wrong since tags, while since tags are
116 // transformed. In this case the program shall be terminated.
117 Cerr() << xd
<< Endl();
122 Cout() << "Unknown error." << Endl();
124 // pFileParsePerformers = new FileParsePerformers( *pRepository );
129 FileParsePerformers::FileParsePerformers( ary::Repository
& io_rRepository
,
130 ParserInfo
& io_rParserInfo
)
132 aDistributor(io_rRepository
, io_rParserInfo
),
133 rRepository( io_rRepository
),
134 rParserInfo(io_rParserInfo
)
136 DYN
csi::dsapi::Context_Docu
*
138 = new csi::dsapi::Context_Docu( aDistributor
.DocuTokens_Receiver() );
139 pTokens
= new csi::uidl::TokenParser_Uidl( aDistributor
.CodeTokens_Receiver(), *dpDocuContext
);
140 pFileParseEnvironment
141 = new csi::uidl::PE_File(aDistributor
,rParserInfo
);
143 aDistributor
.SetTokenProvider(*pTokens
);
144 aDistributor
.SetTopParseEnvironment(*pFileParseEnvironment
);
148 FileParsePerformers::ParseFile( const char * i_sFullPath
)
150 csv::File
aFile(i_sFullPath
);
152 aFile
.open( csv::CFM_READ
);
153 csv_assert( aFile
.is_open() );
154 aFileLoader
.LoadText(aFile
);
157 rParserInfo
.Set_CurFile(i_sFullPath
, true); // true = count lines
158 pTokens
->Start(aFileLoader
);
159 aDistributor
.Reset();
162 aDistributor
.TradeToken();
163 } while ( NOT aFileLoader
.IsFinished() );
166 } // namespace autodoc
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */