summaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 19841c123414393b1c5035db6ccc5a68567a0c4a (plain)
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
#include <iostream>
#include <string>
#include "parse/lex.hpp"
#include "parse/parseerror.hpp"
#include "ast/ast.hpp"
#include <serialiser_texttree.hpp>

extern AST::Crate Parse_Crate(::std::string mainfile);
extern void ResolvePaths(AST::Crate& crate);
extern AST::Flat Convert_Flatten(const AST::Crate& crate);

/// main!
int main(int argc, char *argv[])
{
    try
    {
        AST::Crate crate = Parse_Crate("samples/1.rs");

        Serialiser_TextTree s_tt(::std::cout);
        Serialiser& s = s_tt;
        s << crate;
    
        // Resolve names to be absolute names (include references to the relevant struct/global/function)
        ResolvePaths(crate);

        // Typecheck / type propagate module (type annotations of all values)

        // Flatten modules into "mangled" set
        AST::Flat flat_crate = Convert_Flatten(crate);

        // Convert structures to C structures / tagged enums
        //Convert_Render(flat_crate, stdout);
    }
    catch(const ParseError::Base& e)
    {
        ::std::cerr << "Parser Error: " << e.what() << ::std::endl;
    }
    return 0;
}