OpenCores
URL https://opencores.org/ocsvn/theia_gpu/theia_gpu/trunk

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [new_compiler/] [Main.cpp] - Blame information for rev 202

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 202 diegovalve
/* This program is free software. It comes without any warranty, to
2
 * the extent permitted by applicable law. You can redistribute it
3
 * and/or modify it under the terms of the Do What The Fuck You Want
4
 * To Public License, Version 2, as published by Sam Hocevar. See
5
 * http://sam.zoy.org/wtfpl/COPYING for more details. */
6
 
7
#include "Compiler.h"
8
#include "Preprocessor.h"
9
#include <string>
10
#include <iostream>
11
#include <fstream>
12
#include <cstring>
13
 
14
Preprocessor PP;
15
 
16
int main(int argc, char * argv[]) {
17
        // make sure we received a filename
18
        if (argc != 2) {
19
                std::cerr << "Usage: ./ini-parser [FILENAME]" << std::endl;
20
                return 255;
21
        }
22
 
23
 
24
std::cout << "---------------------------------------------------------------\n";
25
std::cout << "  \n";
26
std::cout << " _/_/_/_/_/  _/                  _/            \n";
27
std::cout << "   _/      _/_/_/      _/_/          _/_/_/   \n";
28
std::cout << "  _/      _/    _/  _/_/_/_/  _/  _/    _/    \n";
29
std::cout << " _/      _/    _/  _/        _/  _/    _/     \n";
30
std::cout << "_/      _/    _/    _/_/_/  _/    _/_/_/      \n";
31
std::cout << "\n";
32
std::cout << "\n";
33
std::cout << "---------------------------------------------------------------\n";
34
        // try and open the INI file
35
        TheiaCompiler * Compiler;
36
        try {
37
                // - means stdin, not a file named '-'
38
                if (strcmp(argv[1], "-") == 0) {
39
 
40
                        Compiler = new TheiaCompiler(std::cin);
41
                } else {
42
                        PP.Execute(argv[1]);
43
 
44
                        Compiler = new TheiaCompiler( std::string(argv[1])+ ".preprocessed");
45
                }
46
        } catch (std::string error) {
47
                std::cerr << "ERROR: " << error << std::endl;
48
                return 255;
49
        }
50
        Compiler->Print();
51
 
52
        std::ofstream ofs;
53
        ofs.open("code.list");
54
        if (!ofs.good())
55
        {
56
                std::cout << "Error could not open file for write 'code.mem'\n";
57
                return 0;
58
        }
59
 
60
        ofs << Compiler->GetHexCodeDump();
61
        ofs.close();
62
        ofs.open("code.mem");
63
        ofs << Compiler->PostProcess("code.list");
64
        ofs.close();
65
 
66
    delete Compiler;
67
        return 0;
68
}
69
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.