-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
83 lines (59 loc) · 1.61 KB
/
Copy pathmain.cpp
File metadata and controls
83 lines (59 loc) · 1.61 KB
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
73
74
75
76
77
78
79
80
81
82
83
// LScript 1.0 | Abthahi Ahmed Rifat
#include <iostream>
#include <fstream>
#include "includes/Tokenizer.hpp"
#include "includes/Parser.hpp"
#include "includes/Interpreter.hpp"
#include "includes/Variables.hpp"
#include "includes/global.hpp"
using namespace std;
int main(int argc, char *argv[])
{
if (argc > 1){
ifstream file(argv[1]);
if (file.is_open()){
if (argc > 2){
debugLanguage = argv[2];
}
string line;
Tokenizer tokenizer = Tokenizer();
while(getline(file, line)){
if (line != "") tokenizer.tokenize(line);
}
Parser parser = Parser(tokenizer.getTokens());
if (parser.parse()){
// cout<<"[i] Parsing done...!"<<endl;
Interpreter interpreter = Interpreter(tokenizer.getTokens());
interpreter.interprete();
cout<<endl;
cout<<"[i] Code executed successfully."<<endl;
}
}else{
cout<<"No such file is found to interprete!"<<endl;
}
}else{
// CLI
cout<<" Welcome to LScript 1.1.1 | Created by Abthahi Ahmed Rifat"<<endl;
cout<<" Copyright (c) 2024"<<endl;
cout<<endl;
cout<<endl;
string command;
Variables var_store;
while (true){
cout<<"[LS] -> ";
getline(cin, command);
if (command != ""){
Tokenizer tokenizer = Tokenizer();
tokenizer.tokenize(command);
// tokenizer.showTokens();
Parser parser = Parser(tokenizer.getTokens());
if (parser.parse()){
Interpreter interpreter = Interpreter(tokenizer.getTokens(), var_store);
interpreter.interprete();
var_store = interpreter.getVariableStore();
}
}
}
}
return 0;
}