1// Copyright 2017 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#pragma once
6
7#include <fstream>
8#include <functional>
9#include <list>
10#include <map>
11#include <string>
12
13#include "generator.h"
14#include "types.h"
15
16const std::map<std::string, std::string>& get_type_to_default_suffix();
17const std::map<std::string, Generator&>& get_type_to_generator();
18
19class AbigenGenerator {
20public:
21    AbigenGenerator(bool verbose)
22        : verbose_(verbose) {}
23    bool AddSyscall(Syscall&& syscall);
24    bool Generate(const std::map<std::string, std::string>& type_to_filename);
25    bool verbose() const;
26
27private:
28    bool generate_one(const std::string& output_file,
29                      Generator& generator, const std::string& type);
30    void print_error(const char* what, const std::string& file);
31
32    std::list<Syscall> calls_;
33    int next_index_ = 0;
34    const bool verbose_;
35};
36