Files
str/src/vm/commands/indent.ts

25 lines
614 B
TypeScript

import {Command, ParseContext, StrTerm} from "./command.js";
import {LexInput} from "../lexer.js";
export type IndentData = {
type: 'space'|'tab',
level?: StrTerm,
}
export class Indent extends Command<IndentData> {
async attemptParse(context: ParseContext): Promise<IndentData> {
return {
type: context.popKeywordInSet(['space', 'tab']).value,
level: await context.popOptionalTerm(),
}
}
isParseCandidate(token: LexInput): boolean {
return this.isKeyword(token, 'indent')
}
getDisplayName(): string {
return 'indent'
}
}