MLLIF
a MLIR-based Language to Language Interoperability Flyover
Loading...
Searching...
No Matches
main.cxx
Go to the documentation of this file.
1
/*
2
* Copyright 2025 Yeong-won Seo
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#include "
pch.h
"
18
19
#include <memory>
20
#include <
mllif/Backend/C++/CxxBridgeGen.h
>
21
#include <
mllif/Backend/C++/CxxDeclGen.h
>
22
#include <
mllif/Backend/C++/Type.h
>
23
#include <
mllif/Backend/Context.h
>
24
#include <
mllif/Backend/Decl.h
>
25
#include <
mllif/Backend/Stdin.h
>
26
27
static
void
PrintErrors(
const
mllif::MLLIFContext
&context) {
28
for
(
auto
error : context.
errors
()) {
29
std::cerr <<
"\x1b[0;31merror\x1b[0m: "
<< error.what() << std::endl;
30
}
31
}
32
33
auto
main
() ->
int
{
34
auto
msm =
mllif::Stdin::ReadToEnd
();
35
36
rapidxml::xml_document<> doc;
37
doc.parse<0>(msm.data());
38
39
mllif::MLLIFContext
context;
40
const
auto
root =
mllif::Decl::Create
(context, doc.first_node(),
nullptr
);
41
42
if
(!context) {
43
goto
ERROR;
44
}
45
46
{
47
mllif::cxx::CxxDeclGen
declGen;
48
declGen.
handleDecl
(context, root, std::cout, 0);
49
50
if
(!context) {
51
goto
ERROR;
52
}
53
}
54
55
{
56
mllif::cxx::CxxBridgeGen
wrapperGen;
57
wrapperGen.
handleDecl
(context, root, std::cout, 0);
58
59
if
(!context) {
60
goto
ERROR;
61
}
62
}
63
64
return
EXIT_SUCCESS;
65
66
ERROR:
67
PrintErrors(context);
68
return
EXIT_FAILURE;
69
}
Type.h
main
auto main() -> int
Definition
main.cxx:33
pch.h
Context.h
CxxBridgeGen.h
CxxDeclGen.h
Decl.h
Stdin.h
mllif::BridgeGen::handleDecl
bool handleDecl(MLLIFContext &context, const std::shared_ptr< Decl > &node, std::ostream &out, std::size_t indent)
Definition
BridgeGen.cxx:20
mllif::Decl::Create
static std::shared_ptr< Decl > Create(MLLIFContext &context, rapidxml::xml_node<> *node, std::shared_ptr< Decl > parent)
Definition
Decl.cxx:60
mllif::MLLIFContext
Definition
Context.h:29
mllif::MLLIFContext::errors
const std::vector< Error > & errors() const
Definition
Context.h:33
mllif::cxx::CxxBridgeGen
Definition
CxxBridgeGen.h:23
mllif::cxx::CxxDeclGen
Definition
CxxDeclGen.h:22
mllif::Stdin::ReadToEnd
static std::vector< char > ReadToEnd()
Reads stdin until EOF.
Definition
Stdin.cxx:20
mllif
Backend
C++
lib
main.cxx
Generated on Mon May 12 2025 01:41:15 for MLLIF by
1.13.2