Implement runfile and support for .str.rc

This commit is contained in:
2026-04-10 09:58:41 -05:00
parent a418f9a89f
commit 4dec54893c
5 changed files with 60 additions and 18 deletions

View File

@@ -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 })
})
}
}