Fixed a considerable amount of compiler errors and changed the lexer error handling...
[fridhskrift.git] / main.cpp
blob06803ed4d704aed522187d3ce6bec3cf266a7f16
1 #include <iostream>
2 #include <string>
3 #include <vector>
4 #include <fridh/lexer.hpp>
5 #include <ail/file.hpp>
6 #include <fridh/interpreter.hpp>
8 bool perform_lexer_test(std::string const & input, std::string const & output)
10 std::string code;
11 if(!ail::read_file(input, code))
13 std::cout << "Unable to read input" << std::endl;
14 return false;
17 std::vector<fridh::line_of_code> lines;
18 std::string error;
19 fridh::lexer lexer(code, lines);
20 if(!lexer.parse())
22 std::cout << "Error: " << error << std::endl;
23 return false;
26 ail::write_file(output, fridh::visualise_lexemes(lines));
27 return true;
30 int main(int argc, char ** argv)
32 if(argc != 3)
34 std::cout << argv[0] << " <input> <output>" << std::endl;
35 return 1;
38 perform_lexer_test(argv[1], argv[2]);
40 return 0;