str/src/vm/commands/lipsum.ts

22 lines
590 B
TypeScript

import {Command, ParseContext, StrTerm} from './command.js'
import {LexInput} from '../lexer.js'
export type LipsumData = { length: StrTerm, type: 'word'|'line'|'para' }
export class Lipsum extends Command<LipsumData> {
attemptParse(context: ParseContext): LipsumData {
return {
length: context.popTerm(),
type: context.popKeywordInSet(['word', 'line', 'para']).value,
}
}
getDisplayName(): string {
return 'lipsum'
}
isParseCandidate(token: LexInput): boolean {
return this.isKeyword(token, 'lipsum')
}
}