Skip to content

Commit

Permalink
0.19.0 (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
FineArchs committed Jul 30, 2024
1 parent 8f08bd5 commit 31aad17
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 36 deletions.
76 changes: 44 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"aiscript0_16_0": "npm:@syuilo/aiscript@0.16.0",
"aiscript0_17_0": "npm:@syuilo/aiscript@0.17.0",
"aiscript0_18_0": "npm:@syuilo/aiscript@0.18.0",
"aiscript0_19_0": "npm:@syuilo/aiscript@0.19.0",
"prismjs": "^1.29.0",
"vue": "^3.4.31",
"vue-prism-editor": "^2.0.0-alpha.2"
Expand Down
11 changes: 7 additions & 4 deletions src/MainArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@

<script lang="ts">
export const versions = [
"next",
// "next",
"develop",
"0.19.0",
"0.18.0",
"0.17.0",
"0.16.0",
"0.15.0",
"0.14.1",
] as const;
export const latest = "0.18.0" as const;
export const latest = "0.19.0" as const;
export type Log = {
id: number;
type?: string;
Expand All @@ -57,8 +58,9 @@ export type Log = {
import { ref, watch } from "vue";
import Editor from "@common/Editor.vue";
import Container from "@common/Container.vue";
import * as Next from "@/versions/next/index.ts";
// import * as Next from "@/versions/next/index.ts";
import * as Develop from "@/versions/develop/index.ts";
import * as V0_19_0 from "@/versions/0.19.0/index.ts";
import * as V0_18_0 from "@/versions/0.18.0/index.ts";
import * as V0_17_0 from "@/versions/0.17.0/index.ts";
import * as V0_16_0 from "@/versions/0.16.0/index.ts";
Expand All @@ -69,8 +71,9 @@ const props = defineProps<{
ver: (typeof versions)[number];
}>();
const { parse, exec, version, samples } = {
next: Next,
// next: Next,
develop: Develop,
"0.19.0": V0_19_0,
"0.18.0": V0_18_0,
"0.17.0": V0_17_0,
"0.16.0": V0_16_0,
Expand Down
56 changes: 56 additions & 0 deletions src/versions/0.19.0/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Interpreter, Parser, values, utils, Ast } from "./version.ts";
import { version, samples } from "./version.ts";
import type { Log } from "@/MainArea.vue";

export { version, samples };

let ast: Ast.Node[] = [];
let interpreter: Interpreter | null = null;

export function parse(code: string): string {
ast = Parser.parse(code);
return JSON.stringify(ast, null, "\t");
}

export async function exec(io: {
in: (q: string) => Promise<string>;
out: (l: Log) => void;
end: (l: Log) => void;
err: (e: any) => void;
}): Promise<void> {
interpreter?.abort();
interpreter = new Interpreter(
{},
{
in: io.in,
out: (value: values.Value) => {
io.out({
id: Math.random(),
type: value.type,
text: utils.valToString(value, true),
print: true,
});
},
err: io.err,
log: (type: string, params: Record<string, any>) => {
switch (type) {
case "end":
io.end({
id: Math.random(),
text: utils.valToString(params.val, true),
print: false,
});
break;
default:
break;
}
},
},
);

try {
await interpreter.exec(ast);
} catch (e) {
io.err(e);
}
}
18 changes: 18 additions & 0 deletions src/versions/0.19.0/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {
Interpreter,
Parser,
values,
utils,
Ast,
} from "aiscript0_19_0";
export { Interpreter, Parser, values, utils, Ast };
export const version = "0.19.0";
export const samples = {
["Hello AiScript"]: '<: "Hello, AiScript!"',
FizzBazz: `for (let i, 100) {
<: if (i % 15 == 0) "FizzBuzz"
elif (i % 3 == 0) "Fizz"
elif (i % 5 == 0) "Buzz"
else i
}`,
};

0 comments on commit 31aad17

Please sign in to comment.