22 lines
635 B
TypeScript
22 lines
635 B
TypeScript
|
|
import {log} from './log.js'
|
||
|
|
import {Lifecycle} from './util/lifecycle.js'
|
||
|
|
import {Input} from './vm/input.js'
|
||
|
|
import {Lexer} from "./vm/lexer.js";
|
||
|
|
import {Parser} from "./vm/parser.js";
|
||
|
|
import {commands} from "./vm/commands/index.js";
|
||
|
|
|
||
|
|
const lifecycle = new Lifecycle()
|
||
|
|
const input = new Input()
|
||
|
|
input.adoptLifecycle(lifecycle)
|
||
|
|
input.subscribe(line => log.verbose('input', { line }))
|
||
|
|
|
||
|
|
const lexer = new Lexer(input)
|
||
|
|
lexer.subscribe(token => log.verbose('token', token))
|
||
|
|
|
||
|
|
const parser = new Parser(lexer, commands)
|
||
|
|
parser.subscribe(exec => log.verbose('exec', exec))
|
||
|
|
|
||
|
|
input.setupPrompt()
|
||
|
|
|
||
|
|
process.on('SIGINT', () => lifecycle.close())
|