-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
31 lines (21 loc) · 864 Bytes
/
main.ts
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
import { Parser } from "./compiler/parser.ts";
import { Analyze } from "./compiler/analyses.ts";
import { Generate } from "./compiler/generator.ts";
import { serveDir, serveFile } from "./deps.ts";
import { join } from "https://deno.land/[email protected]/path/win32.ts";
const decode = new TextDecoder("utf-8")
const fileContent = Deno.readFileSync("./app/app.scale")
const content = decode.decode(fileContent)
const parsed = Parser(content)
const analysis = Analyze(parsed)
const generatedCode = Generate(parsed, analysis)
Deno.writeTextFileSync("./app/app.gen.js", generatedCode)
Deno.serve((req: Request) => {
const p = new URL(req.url).pathname
if (p === '/') {
return serveFile(req, './app/index.html')
} else if (p === '/app.gen.js') {
return serveFile(req, './app/app.gen.js')
}
return new Response('Not found', { status: 404 })
})