-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
311 lines (239 loc) · 10.7 KB
/
index.html
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<!DOCTYPE html>
<html>
<head>
<title>mehd</title>
<link rel="icon" type="image/png" sizes="16x16" href="img/mehd.png">
<script src="js/lib/jquery-2.0.3.min.js"></script>
<script src="js/lib/CCapture.min.js"></script>
<script src="js/lib/download.js"></script>
<script src="js/lib/gif.js"></script>
<script src="js/lib/webm-writer-0.2.4.js"></script>
<script src="js/peg-0.10.0.js"></script>
<script src="js/frameexporter.js"></script>
<script src="js/vcdisplay.js"></script>
<script src="js/syntaxHighlighter.js"></script>
<script src="js/luaengine.js"></script>
<script src="js/fontmgr.js"></script>
<script src="js/undomgr.js"></script>
<script src="js/scrollbar.js"></script>
<script src="js/statusbar.js"></script>
<script src="js/selection.js"></script>
<script src="js/editor.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<span id="versionSpan" style="user-select: none;float:left">mehd vx.x</span><span id="fpsspan" style="user-select: none"> - </span>
<canvas id="maincanvas" width="1100" height="650" style="float:left; clear:both"></canvas>
<img id="fontImage" src="img/font5x7_2.png" style="display:none" />
<img id="arrowUp" src="img/arrowUp.png" style="display:none" />
<img id="arrowDown" src="img/arrowDown.png" style="display:none" />
<div id="luaGrammar" style="display:none">
start=(instr:instruction newLine)*
instruction=[ \t]* comm:comment {return comm; } /
[ \t]* assi:assignmentStatement {return assi;} /
[ \t]* fori:forStatement {return fori;} /
[ \t]* iffe:ifStatement {return iffe;} /
[ \t]* fcall:functionCallStatement {return fcall;} /
[ \t]* fdecl:functionDeclStatement {return fdecl;} /
[ \t]* increment:incrementStatement {return increment;} /
[ \t]* product:productStatement {return product;} /
[ \t]* lab:labelStatement {return lab;} /
[ \t]* gotoLab:gotoStatement {return gotoLab;} /
[ \t]* retStat:returnStatement {return retStat;} /
[ \t]* emptyLine
/* return */
returnStatement="return" [ \t]* xpr:expression { return ['RETURN',xpr] }
/* labels & "goto considered harmful" */
labelStatement="::" lname:labelName "::" {return lname; }
gotoStatement="goto" [ ] lname:labelName {return ['GOTO',lname] }
/* postincrement operators statements */
incrementStatement=vname:variableName "+=" rval:expression { return ['POSTINCREMENT',vname,rval,'+'] }
productStatement=vname:variableName "*=" rval:expression { return ['POSTINCREMENT',vname,rval,'*'] }
/* comment statement */
comment="--" commentText:[ A-Za-z0-9\.\;\,\:\-\_\?\'\^\!\"\$\(\)\=\/\#]* { return ['COMMENT',commentText.join('')]; }
/* assignment statement */
assignmentStatement=lval:leftval "=" rval:expression { return ['ASSIGNMENT',lval,rval] }
leftval = arrayElement/variableName;
arrayElement = vn:vName "\[" aindex:expression "\]" { return ['ARRAYELEMENT',vn,aindex] }
vName = the1var:[a-zA-Z] the2var:[a-zA-Z0-9\$]* { return ['VARIABLE',the1var+the2var.join("")]; }
variableName = the1var:[a-zA-Z] the2var:[a-zA-Z0-9\$]* { return ['VARIABLE',the1var+the2var.join("")]; }
labelName = the1var:[a-zA-Z\_] the2var:[a-zA-Z0-9\$]* { return ['LABEL',the1var+the2var.join("")]; }
/* if statement */
ifStatement="if" [ ]+ expr1:expression rop:ifRelop expr2:expression [ ]+ "then" "\n" ifinstrs:(instruction)* "else"? elseinstrs:(instruction)* "end"
{
var ifArray=new Array();
for (var i = 0; i < ifinstrs.length; i++)
{
if (ifinstrs[i][0].length>0)
{
ifArray.push([ifinstrs[i]]);
}
}
var elseArray=new Array();
for (var i = 0; i < elseinstrs.length; i++)
{
if (elseinstrs[i][0].length>0)
{
elseArray.push([elseinstrs[i]]);
}
}
return ["IF",expr1,expr2,rop,ifArray,elseArray];
}
ifRelop="<"/"<="/"=="/">="/">"/"!="
/* function declaration */
functionDeclStatement = "function" [ ]+ funname:functionName "(" alist:arglist? ")" "\n"
instrs:(instruction)* "end"
{
var dataArray=new Array();
for (var i = 0; i < instrs.length; i++)
{
if (instrs[i][0].length!=0)
{
dataArray.push([instrs[i]]);
}
}
return ["FUNDECL",funname,alist,dataArray];
}
/* expressions */
expression=additive
additiveOperator = "+" { return "+"; } / "-" { return "-"; }
multiplicativeOperator = "*" { return "*"; } / "/" { return "/"; }
modulusOperator = "\%"
exponentiationOperator = "^"
additive = head:multiplicative tail:(additiveOperator multiplicative)*
{
var result = head;
for (var i = 0; i < tail.length; i++)
{
result =
{
operator: tail[i][0],
left: result,
right: tail[i][1]
};
}
return result;
}
multiplicative = head:exponentiative tail:(multiplicativeOperator exponentiative)*
{
var result = head;
for (var i = 0; i < tail.length; i++)
{
result =
{
operator: tail[i][0],
left: result,
right: tail[i][1]
};
}
return result;
}
exponentiative = head:modular tail:(exponentiationOperator modular)*
{
var result = head;
for (var i = 0; i < tail.length; i++)
{
result =
{
operator: tail[i][0],
left: result,
right: tail[i][1]
};
}
return result;
}
modular = head:primary tail:(modulusOperator primary)*
{
var result = head;
for (var i = 0; i < tail.length; i++)
{
result =
{
operator: tail[i][0],
left: result,
right: tail[i][1]
};
}
return result;
}
primary=floatNumber/
integerNumber/
quotedString/
arrayElement/
functionCallStatement/
variableName/
arrayDecl/
"(" additive:additive ")" { return additive; }
/* array declaration */
arrayDecl="{" arrlist:arrarglist? "}"
arrarglist = head:argument tail:("," argument)*
{
var dataArray=new Array();
dataArray.push(head);
for (var i = 0; i < tail.length; i++)
{
dataArray.push(tail[i][1]);
}
return ["ARRARGLIST",dataArray];
}
/* for statement */
numericVal=floatNumber/integerNumber;
forStatement="for" [ ]+ vname:variableName "=" fromi:expression "," toi:expression ","? stri:expression? [ ]+ "do" "\n"
instrs:(instruction)* "end"
{
var dataArray=new Array();
for (var i = 0; i < instrs.length; i++)
{
if (instrs[i][0].length!=0)
{
dataArray.push([instrs[i]]);
}
}
return ["FOR",vname,fromi,toi,dataArray,stri];
}
functionCallStatement=funname:functionName "(" alist:arglist? ")" { return ['FUNCTIONCALL',funname,alist] }
functionName = the1var:[a-zA-Z] the2var:[a-zA-Z0-9\$]* { return the1var+the2var.join(""); }
arglist = head:argument tail:("," argument)*
{
var dataArray=new Array();
dataArray.push(head);
for (var i = 0; i < tail.length; i++)
{
dataArray.push(tail[i][1]);
}
return ["FUNARGLIST",dataArray];
}
argument=expression
integerNumber = sign:"-"? digits:[0-9]+
{
var val=parseInt(digits.join(""), 10);
if (sign=="-")
{
return -val;
}
return val;
}
floatNumber = sign:"-"? idigits:([0-9]+)? "." fdigits:[0-9]+
{
var val=0;
var ival=0;
var fval=fdigits.join("");
if (idigits)
{
ival=parseInt(idigits.join(""), 10);
}
var concat=ival.toString()+"."+fval.toString();
val=parseFloat(concat);
if (sign=="-")
{
return -val;
}
return val;
}
doubleQuotes="\""
quotedString = doubleQuotes stringCorpus:[a-zA-Z0-9\.\-\=\;\,\: ]* doubleQuotes { return stringCorpus.join(''); }
emptyLine= "\n"
newLine="\n"
</div>
</body>
</html>