28 lines
718 B
TypeScript
28 lines
718 B
TypeScript
|
|
import {Command, CommandData, ParseContext, StrTerm} from "./command.js";
|
||
|
|
import {Executable} from "../parse.js";
|
||
|
|
import {LexInput} from "../lexer.js";
|
||
|
|
|
||
|
|
export type OnData = {
|
||
|
|
type: 'line'|'word',
|
||
|
|
specific: StrTerm,
|
||
|
|
exec: Executable<CommandData>,
|
||
|
|
}
|
||
|
|
|
||
|
|
export class On extends Command<OnData> {
|
||
|
|
async attemptParse(context: ParseContext): Promise<OnData> {
|
||
|
|
return {
|
||
|
|
type: context.popKeywordInSet(['line', 'word']).value,
|
||
|
|
specific: context.popTerm(),
|
||
|
|
exec: await context.popExecutable(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
getDisplayName(): string {
|
||
|
|
return 'on'
|
||
|
|
}
|
||
|
|
|
||
|
|
isParseCandidate(token: LexInput): boolean {
|
||
|
|
return this.isKeyword(token, 'on')
|
||
|
|
}
|
||
|
|
}
|