-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
35 lines (34 loc) · 979 Bytes
/
main.cpp
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
//
// Created by Lars on 10.04.2017.
//
#include <iostream>
#include <cstring>
#include "Lexer.h"
#include "Parser.h"
void start(std::string sourcePath){
Lexer *lex = new Lexer(sourcePath);
std::vector<std::string> *symTab = lex->getSymbolTable();
Parser *parser = new Parser(lex);
parser->start();
parser->printAST(symTab);
std::cout << "=====================================================" << std::endl;
}
int main(int argc, char *argv[]) {
if (argc>1) {
start(argv[1]);
} else {
std::string fileName = "tmp.go";
remove(fileName.c_str());
std::ofstream outfile (fileName,std::ofstream::binary);
std::string end = "end";
std::string line = "";
do {
outfile.write (line.c_str(),line.size());
std::getline(std::cin, line);
} while(end.compare(line));
outfile.close();
start(fileName);
remove(fileName.c_str());
}
return 0;
}