Skip to content

Commit 31aad17

Browse files
authored
0.19.0 (#162)
1 parent 8f08bd5 commit 31aad17

File tree

5 files changed

+126
-36
lines changed

5 files changed

+126
-36
lines changed

package-lock.json

Lines changed: 44 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"aiscript0_16_0": "npm:@syuilo/aiscript@0.16.0",
1717
"aiscript0_17_0": "npm:@syuilo/aiscript@0.17.0",
1818
"aiscript0_18_0": "npm:@syuilo/aiscript@0.18.0",
19+
"aiscript0_19_0": "npm:@syuilo/aiscript@0.19.0",
1920
"prismjs": "^1.29.0",
2021
"vue": "^3.4.31",
2122
"vue-prism-editor": "^2.0.0-alpha.2"

src/MainArea.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@
3737

3838
<script lang="ts">
3939
export const versions = [
40-
"next",
40+
// "next",
4141
"develop",
42+
"0.19.0",
4243
"0.18.0",
4344
"0.17.0",
4445
"0.16.0",
4546
"0.15.0",
4647
"0.14.1",
4748
] as const;
48-
export const latest = "0.18.0" as const;
49+
export const latest = "0.19.0" as const;
4950
export type Log = {
5051
id: number;
5152
type?: string;
@@ -57,8 +58,9 @@ export type Log = {
5758
import { ref, watch } from "vue";
5859
import Editor from "@common/Editor.vue";
5960
import Container from "@common/Container.vue";
60-
import * as Next from "@/versions/next/index.ts";
61+
// import * as Next from "@/versions/next/index.ts";
6162
import * as Develop from "@/versions/develop/index.ts";
63+
import * as V0_19_0 from "@/versions/0.19.0/index.ts";
6264
import * as V0_18_0 from "@/versions/0.18.0/index.ts";
6365
import * as V0_17_0 from "@/versions/0.17.0/index.ts";
6466
import * as V0_16_0 from "@/versions/0.16.0/index.ts";
@@ -69,8 +71,9 @@ const props = defineProps<{
6971
ver: (typeof versions)[number];
7072
}>();
7173
const { parse, exec, version, samples } = {
72-
next: Next,
74+
// next: Next,
7375
develop: Develop,
76+
"0.19.0": V0_19_0,
7477
"0.18.0": V0_18_0,
7578
"0.17.0": V0_17_0,
7679
"0.16.0": V0_16_0,

src/versions/0.19.0/index.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Interpreter, Parser, values, utils, Ast } from "./version.ts";
2+
import { version, samples } from "./version.ts";
3+
import type { Log } from "@/MainArea.vue";
4+
5+
export { version, samples };
6+
7+
let ast: Ast.Node[] = [];
8+
let interpreter: Interpreter | null = null;
9+
10+
export function parse(code: string): string {
11+
ast = Parser.parse(code);
12+
return JSON.stringify(ast, null, "\t");
13+
}
14+
15+
export async function exec(io: {
16+
in: (q: string) => Promise<string>;
17+
out: (l: Log) => void;
18+
end: (l: Log) => void;
19+
err: (e: any) => void;
20+
}): Promise<void> {
21+
interpreter?.abort();
22+
interpreter = new Interpreter(
23+
{},
24+
{
25+
in: io.in,
26+
out: (value: values.Value) => {
27+
io.out({
28+
id: Math.random(),
29+
type: value.type,
30+
text: utils.valToString(value, true),
31+
print: true,
32+
});
33+
},
34+
err: io.err,
35+
log: (type: string, params: Record<string, any>) => {
36+
switch (type) {
37+
case "end":
38+
io.end({
39+
id: Math.random(),
40+
text: utils.valToString(params.val, true),
41+
print: false,
42+
});
43+
break;
44+
default:
45+
break;
46+
}
47+
},
48+
},
49+
);
50+
51+
try {
52+
await interpreter.exec(ast);
53+
} catch (e) {
54+
io.err(e);
55+
}
56+
}

src/versions/0.19.0/version.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
Interpreter,
3+
Parser,
4+
values,
5+
utils,
6+
Ast,
7+
} from "aiscript0_19_0";
8+
export { Interpreter, Parser, values, utils, Ast };
9+
export const version = "0.19.0";
10+
export const samples = {
11+
["Hello AiScript"]: '<: "Hello, AiScript!"',
12+
FizzBazz: `for (let i, 100) {
13+
<: if (i % 15 == 0) "FizzBuzz"
14+
elif (i % 3 == 0) "Fizz"
15+
elif (i % 5 == 0) "Buzz"
16+
else i
17+
}`,
18+
};

0 commit comments

Comments
 (0)