2026-02-10 04:15:33 +00:00
|
|
|
import {Command, ParseContext, unwrapString} from "./command.js";
|
2025-11-12 03:37:32 +00:00
|
|
|
import {LexInput} from "../lexer.js";
|
2026-02-10 04:15:33 +00:00
|
|
|
import {StrVM} from "../vm.js";
|
|
|
|
|
import {Awaitable} from "../../util/types.js";
|
2025-11-12 03:37:32 +00:00
|
|
|
|
2026-02-10 04:15:33 +00:00
|
|
|
export type LinesData = {}
|
2025-11-12 03:37:32 +00:00
|
|
|
|
|
|
|
|
export class Lines extends Command<LinesData> {
|
|
|
|
|
attemptParse(context: ParseContext): LinesData {
|
2026-02-10 04:15:33 +00:00
|
|
|
return {}
|
2025-11-12 03:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDisplayName(): string {
|
|
|
|
|
return 'lines'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isParseCandidate(token: LexInput): boolean {
|
|
|
|
|
return this.isKeyword(token, 'lines')
|
|
|
|
|
}
|
2026-02-10 04:15:33 +00:00
|
|
|
|
|
|
|
|
execute(vm: StrVM, data: LinesData): Awaitable<StrVM> {
|
|
|
|
|
return vm.tapInPlace(ctx =>
|
|
|
|
|
ctx.replaceSubject(sub => ({
|
|
|
|
|
term: 'destructured',
|
|
|
|
|
value: unwrapString(sub)
|
|
|
|
|
.split('\n')
|
|
|
|
|
.map((line, idx) => ({ prefix: idx ? '\n' : undefined, value: line })),
|
|
|
|
|
})))
|
|
|
|
|
}
|
2025-11-12 03:37:32 +00:00
|
|
|
}
|