-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
72 lines (69 loc) · 1.7 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include <fstream>
#include <string>
#include "include/lexer.h"
#include "include/imports.h"
int main() {
std::string mode;
std::cout << "From file(y) or from console(n): ";
std::cin >> mode;
if (mode == "y") {
std::string filepath;
std::cout << "Enter filepath: ";
std::cin >> filepath;
std::fstream file;
file.open(filepath, std::ios::in);
if (!file || !file.is_open()) {
std::cout << "ERROR: no file with such filepath" << std::endl;
return 0;
}
std::string s;
lexer *lex = initLexer("");
while (!file.eof()) {
file >> s;
if (s[0] == '@') {
if (s == "@debug") turn_on_debug();
if (s == "@precision") {
int x;
file >> x;
set_precision(x);
}
} else {
updateLexer(lex, s);
carryToToken(lex);
}
}
file.close();
s = "~";
updateLexer(lex, s);
carryToToken(lex);
}else{
std::string s;
lexer* lex = initLexer("");
while (std::cin >> s){
if (s[0] == '@'){
if (s == "@debug") turn_on_debug();
if (s == "@precision"){
int x;
std::cin >> x;
set_precision(x);
}
}else {
updateLexer(lex, s);
carryToToken(lex);
}
}
}
return 0;
}
//func main : int -> int
//{
//int lol = 5;
//lol = lol + 5;
//return 0;
//}
//@precision 9
//
//float lol=2.342;
//print(lol);
//~