Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Commit 319f380

Browse files
committed
Test playground
1 parent 27034e2 commit 319f380

7 files changed

Lines changed: 103 additions & 23 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
run: |
3535
mkdir demo
3636
mv bin/out.js demo
37+
mv static demo
3738
3839
- name: Deploy to gh-pages branch
3940
uses: peaceiris/actions-gh-pages@v3

build.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.

build.hxml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@
1111

1212
--cpp bin/cpp
1313
#--hl bin/out.hl
14-
15-
# Can also do other targets

deploy.hxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
--library compiletime
77

88
--class-path src
9-
--main Main
9+
--main JSMain
1010

1111
--js bin/out.js

src/JSMain.hx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import js.html.TextAreaElement;
2+
import js.html.Event;
3+
import js.html.InputElement;
4+
import js.Browser;
5+
6+
import base.Preprocessor;
7+
import base.Tokenizer;
8+
import base.Parser;
9+
10+
function main() {
11+
final Preprocessor = new Preprocessor();
12+
final Tokenizer = new Tokenizer();
13+
final Parser = new Parser();
14+
15+
final input_textarea: TextAreaElement = cast Browser.document.getElementById("input");
16+
final output_textarea: TextAreaElement = cast Browser.document.getElementById("output");
17+
18+
input_textarea.onkeypress = function(e:Event) {
19+
try {
20+
final processed = Preprocessor.process(input_textarea.value);
21+
final tokens = Tokenizer.process(processed);
22+
final ast = Parser.process(tokens);
23+
24+
final out_code = base.transpiler.Lua.process(ast);
25+
26+
output_textarea.value = out_code;
27+
} catch(exception) {
28+
output_textarea.value = exception.toString();
29+
}
30+
};
31+
}

src/Main.hx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
using Iterators;
1+
import base.Preprocessor;
22

3-
final CODE: String = CompileTime.readFile("script.e2");
4-
5-
function main() {
6-
final preprocessor = new base.Preprocessor();
7-
final code = preprocessor.process(CODE);
3+
#if sys
84

9-
final tokenizer = new base.Tokenizer();
10-
final tokens = tokenizer.process(code);
5+
final CODE: String = CompileTime.readFile("script.e2");
116

12-
final parser = new base.Parser();
13-
final ast = parser.process(tokens);
7+
final PREPROCESSOR = new base.Preprocessor();
8+
final TOKENIZER = new base.Tokenizer();
9+
final PARSER = new base.Parser();
1410

11+
function main() {
12+
final code = PREPROCESSOR.process(CODE);
13+
final tokens = TOKENIZER.process(code);
14+
final ast = PARSER.process(tokens);
1515
final lua_code = base.transpiler.Lua.process(ast);
1616

17-
#if sys
18-
if (!sys.FileSystem.exists("out"))
19-
sys.FileSystem.createDirectory("out");
17+
if (!sys.FileSystem.exists("out"))
18+
sys.FileSystem.createDirectory("out");
2019

21-
final handle = sys.io.File.write('out/script.lua');
22-
handle.writeString(lua_code);
23-
handle.close();
24-
#end
20+
final handle = sys.io.File.write('out/script.lua');
21+
handle.writeString(lua_code);
22+
handle.close();
2523

2624
trace("Finished transpiling!");
27-
}
25+
}
26+
27+
#end

static/index.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
3+
<head>
4+
<title>ExpressionScript Playground</title>
5+
</head>
6+
7+
<div class="header">
8+
Basic ExpressionScript Playground
9+
</div>
10+
11+
<body>
12+
<textarea id="input" onkeydown="if(event.keyCode===9){var v=this.value,s=this.selectionStart,e=this.selectionEnd;this.value=v.substring(0, s)+' '+v.substring(e);this.selectionStart=this.selectionEnd=s+4;return false;}" rows=50>
13+
@name Example Code
14+
print("Hello world!")
15+
16+
for(I = 1, 5) {
17+
if(I == 4) { continue }
18+
print(I)
19+
}
20+
21+
</textarea>
22+
23+
<textarea readonly id="output" rows=50> </textarea>
24+
25+
<script src="out.js"></script>
26+
</body>
27+
28+
<style>
29+
textarea {
30+
width: 40%;
31+
margin-left: 50px;
32+
background-color: #39464e;
33+
border: none;
34+
outline: none;
35+
color: lightslategray;
36+
}
37+
body {
38+
margin: 0;
39+
background-color:#1f2227;
40+
display: block;
41+
color: lightslategray;
42+
}
43+
44+
div.header {
45+
text-align: center;
46+
background-color: #1f1f7a;
47+
color: #ebebfa;
48+
padding: 0;
49+
height: 50px;
50+
margin: 0;
51+
}
52+
</style>

0 commit comments

Comments
 (0)