-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
50 lines (36 loc) · 889 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <vector>
#include "lib/parser/scanner.h"
using namespace std;
void runLoxScriptFile(char *string);
void showLoxPrompt();
void run(std::string basicString);
int main(int argc, char** argv) {
std::cout << "Hello, World!" << std::endl;
if(argc > 1){
cout << "usage lox [script]";
exit(1);
}else if(argc == 1){
runLoxScriptFile(*argv);
}else{
showLoxPrompt();
}
return 0;
}
void showLoxPrompt() {
while(true){
for (std::string line; std::getline(std::cin, line);) {
std::cout << line << std::endl;
if(line.empty()) break;
run(line);
}
}
}
void run(string basicString) {
auto tokens = tokenizer(basicString);
for(auto token: tokens) {
cout << "token: " << token << endl;
}
}
void runLoxScriptFile(char *string) {
}