#include #include #include #include #include "tokenizer.hpp" std::vector tokenize(std::string code); std::string readFileContents(std::string fname) { std::ifstream ifs(fname); std::string contents( (std::istreambuf_iterator(ifs)), (std::istreambuf_iterator()) ); return contents; } int main(int argc, char* argv[]) { #ifdef DEBUG for (int n = 0; n < argc; n++) { std::cout << "arg" << n << ": " << argv[n] << std::endl; } #endif std::string infile = argc > 1 ? argv[1] : ""; std::string code = ""; if(infile.length() > 0) { code = readFileContents(infile); } Tokenizer tokenizer = Tokenizer(code); #ifdef DEBUG std::cout << "code: " << tokenizer.dump() << std::endl; #endif std::vector tokens = tokenizer.tokenize(); for(int i = 0; i < tokens.size(); i++) { std::cout << tokens[i].value << std::endl; } return 0; }