Implement sub-command parsing + add on/word/line/over commands
This commit is contained in:
25
src/vm/commands/over.ts
Normal file
25
src/vm/commands/over.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {Command, CommandData, ParseContext, StrLVal} from "./command.js";
|
||||
import {Executable} from "../parse.js";
|
||||
import {LexInput} from "../lexer.js";
|
||||
|
||||
export type OverData = {
|
||||
subject: StrLVal,
|
||||
exec: Executable<CommandData>,
|
||||
}
|
||||
|
||||
export class Over extends Command<OverData> {
|
||||
async attemptParse(context: ParseContext): Promise<OverData> {
|
||||
return {
|
||||
subject: context.popLVal(),
|
||||
exec: await context.popExecutable(),
|
||||
}
|
||||
}
|
||||
|
||||
getDisplayName(): string {
|
||||
return 'over'
|
||||
}
|
||||
|
||||
isParseCandidate(token: LexInput): boolean {
|
||||
return this.isKeyword(token, 'over')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user