Implement runfile and support for .str.rc
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {Command, ParseContext, StrTerm} from "./command.js";
|
||||
import {LexInput} from "../lexer.js";
|
||||
import {StrVM} from "../vm.js";
|
||||
|
||||
export class RunFile extends Command<{ path: StrTerm }> {
|
||||
isParseCandidate(token: LexInput): boolean {
|
||||
@@ -13,4 +14,12 @@ export class RunFile extends Command<{ path: StrTerm }> {
|
||||
getDisplayName(): string {
|
||||
return 'runfile'
|
||||
}
|
||||
|
||||
execute(vm: StrVM, data: { path: StrTerm }): Promise<StrVM> {
|
||||
return vm.tapInPlace(async ctx => {
|
||||
await vm.control$.next({ cmd: 'preserve-history' })
|
||||
const path = ctx.resolveString(data.path)
|
||||
await vm.control$.next({ cmd: 'lex-file', path })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user