1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <filesystem>
#include <fstream>
#include <sstream>

#include "expr.hpp"
#include "exprwrapper.hpp"
#include "hdw.hpp"
#include "instrfmt.hpp"
#include "ulmdoc.hpp"

using namespace ulmdoc;

#include <ulm1/_gen_refman_format.cpp>

int
main(int argc, const char **argv)
{
    if (argc != 4) {
        fprintf(stderr, "Example usage: %s isa.txt template.tex out.tex\n",
                argv[0]);
        return 1;
    }

    std::ifstream tex, isa;
    std::string isaTxt = argv[1];
    std::string mainTex = argv[2];
    std::string refmanTex = argv[3];

    tex.open(mainTex);
    if (!tex.is_open()) {
        std::cerr << argv[0] << ": can not open input file '" << mainTex << "'"
                  << std::endl;
    }

    isa.open(isaTxt);
    if (!isa.is_open()) {
        std::cerr << argv[0] << ": can not open input file '" << isaTxt << "'"
                  << std::endl;
    }

    std::ofstream out;
    out.open(refmanTex);
    if (!out.is_open()) {
        std::cerr << argv[0] << ": can not open output file '" << refmanTex
                  << "'" << std::endl;
    }

#include <ulm1/_gen_refman_instr.cpp>

    ulmDoc.print(tex, isa, out);

    tex.close();
    out.close();
}