-
Notifications
You must be signed in to change notification settings - Fork 5
/
E™
executable file
·48 lines (45 loc) · 1016 Bytes
/
E™
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
#!/usr/bin/env node
const fs = require('fs')
const ast = require('./ast')
const compile = require('./compile')
require('yargs')
.option('turbo', {
default: false,
type: 'boolean',
})
.option('output', {
alias: 'o',
default: false,
type: 'boolean',
})
.command({
command: 'compile [input]',
description: 'Compile',
handler: (argv) => {
const code = compile(argv.input, argv.turbo)
if (argv.file) {
fs.writeFileSync(argv.input.replace('E™', 'js'), code, 'utf8')
} else {
console.log(code)
}
},
})
.command({
command: 'ast [input]',
description: 'Compile',
handler: (argv) => {
console.log(JSON.stringify(ast(argv.input), null, 2))
},
})
.command({
command: 'eval [input]',
description: 'Eval',
handler: (argv) => {
eval(compile(argv.input, argv.turbo))
},
})
.command({
command: 'examples',
description: 'Downloads examples',
handler: (argv) => {},
}).argv