4a88efe0d8eb13badfdab67f8babfed6f9a0670b
2 * Copyright 2017 Jacob Lifshay
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #include "json/json.h"
25 #include "json/parser.h"
27 #include "util/optional.h"
32 namespace generate_spirv_parser
34 int generate_spirv_parser_main(int argc
, char **argv
)
36 std::string file_name
;
37 std::string output_directory
;
41 output_directory
= argv
[2];
42 if(argc
!= 3 || (file_name
.size() > 1 && file_name
[0] == '-')
43 || (output_directory
.size() > 1 && output_directory
[0] == '-'))
45 std::cerr
<< "usage: " << argv
[0] << " <input.json> <output-directory>" << std::endl
;
50 auto source
= file_name
== "-" ? json::Source::load_stdin() :
51 json::Source::load_file(std::move(file_name
));
54 auto json_in
= json::parse(&source
);
55 auto ast
= parser::parse(json_in
.duplicate());
56 for(auto &generator
: {
57 generate::Generators::make_spirv_header_generator(),
60 generator
->run(generate::Generator::Generator_args(output_directory
), ast
);
63 std::cerr
<< "generate_spirv_parser is not finished being implemented" << std::endl
;
66 catch(parser::Parse_error
&e
)
68 std::cerr
<< e
.what() << std::endl
;
71 catch(json::Parse_error
&e
)
73 std::cerr
<< e
.what() << std::endl
;
77 catch(std::exception
&e
)
79 std::cerr
<< "error: " << e
.what() << std::endl
;
87 int main(int argc
, char **argv
)
89 return vulkan_cpu::generate_spirv_parser::generate_spirv_parser_main(argc
, argv
);