str/src/vm/commands/lipsum.ts

22 lines
590 B
TypeScript
Raw Normal View History

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