Renamed the intermediary non-sense to parser
[fridhskrift.git] / main.cpp
blob4f985065b919aa4148a784edf10ab50b38f4e6ee
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 fridh::lines_of_code lines;
18 fridh::lexer lexer(code, lines);
20 std::string error;
21 if(!lexer.parse(error))
23 std::cout << "Error: " << error << std::endl;
24 return false;
27 std::cout << "Processed " << lines.size() << " line(s) of code" << std::endl;
29 std::string data = fridh::visualise_lexemes(lines);
31 std::cout << "Output: " << data.size() << " byte(s)" << std::endl;
33 ail::write_file(output, data);
34 return true;
37 int main(int argc, char ** argv)
39 if(argc != 4)
41 std::cout << argv[0] << " lexer <input> <output>" << std::endl;
42 std::cout << argv[0] << " parser <input> <output>" << std::endl;
43 return 1;
46 perform_lexer_test(argv[1], argv[2]);
48 return 0;