-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
132 lines (112 loc) · 3.53 KB
/
main.js
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//Made By BioShot\\
let fs = require("fs");
let linebyline = require("line-by-line");
if(process.argv.length == 3) {
if(process.argv[2].endsWith(".ands")){
if(fs.existsSync(process.argv[2])){
}else{
console.error("Error! The File Does not exist! \nUsage: main.js <filename.ands>");
process.exit(1);
}
}else{
console.error("Usage: main.js <filename.ands>");
process.exit(0);
}
}else{
console.error("Usage: main.js <filename.ands>");
process.exit(0);
}
let lr = new linebyline(process.argv[2]);
let nodebugfound=false;
let vars = {};
let debug = true;
lr.on("line", function(line){
if(line == "" || line == " ")return;
interp(line);
})
function interp(line){
if(line.startsWith("ptext")){
let args = line.split(" ");
args.shift();
let str = args.join(" ").split('"')[1];
if(str == undefined){
let thing = vars[args];
let val = thing.split('"')[1];
if(val == undefined){
console.log(vars[args]);
}else{
console.log(val);
}
}else{
console.log(str);
}
}else if(line.startsWith('"')){
let args = line.split(" ");
args.shift();
let str = line.split('"')[1];
let restt = args.join(" ").split('"')[1];
let argswithout = restt.split(str)[0].split(" ");
console.log(str);
if(argswithout.includes("->")){
let pointer = argswithout[2].split('->')[0];
if(pointer == "ptext"){
console.log(str);
}
}
}else if(line.startsWith("let")){
let varname = line.split(" ")[1];
let varvalue = line.split(" ").splice(3).join(" ");
vars[varname] = varvalue;
if(debug == false){
}else{
console.log(vars);
}
}else if(line.startsWith("if")){
let args = line.split(" ");
args.shift();
let value1 = args[0];
let value2 = args[1];
if(value1 == value2){
let ifcode = args.splice(2).join(" ");
interp(ifcode);
}
}
else{
if(line == "nodebug -> settings"){
debug = false;
nodebugfound = true;
}
let args = line.split(" ");
args.shift();
let str = args.join(" ").split('"')[1];
if(str == undefined){
let lnt = line.split("->")[0]
// console.log(lnt);
let bbt = lnt.split(" ")[0];
let thing = vars[bbt];
// console.log(thing);
//let val = thing.split('"')[1];
if(thing == undefined){
if(line == "nodebug -> settings"){
if(nodebugfound == true){
}
}else if(line.startsWith("//")){
//its a comment.
}
else{
console.error("Unknown keywords in line. keywords: "+line);
}
}else{
let pointer = args[1];
if(pointer == "ptext"){
let strc = thing.split('"')[1];
if(strc == undefined){
console.log(thing)
}else{
console.log(strc);
}
}
}
}
}
}