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