25 lines
572 B
TypeScript
25 lines
572 B
TypeScript
|
|
import {Command, ParseContext, StrTerm} from "./command.js";
|
||
|
|
import {LexInput} from "../lexer.js";
|
||
|
|
|
||
|
|
export type EncloseData = {
|
||
|
|
left?: StrTerm,
|
||
|
|
right?: StrTerm,
|
||
|
|
}
|
||
|
|
|
||
|
|
export class Enclose extends Command<EncloseData> {
|
||
|
|
attemptParse(context: ParseContext): EncloseData {
|
||
|
|
return {
|
||
|
|
left: context.popOptionalTerm(),
|
||
|
|
right: context.popOptionalTerm(),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
getDisplayName(): string {
|
||
|
|
return 'enclose'
|
||
|
|
}
|
||
|
|
|
||
|
|
isParseCandidate(token: LexInput): boolean {
|
||
|
|
return this.isKeyword(token, 'enclose')
|
||
|
|
}
|
||
|
|
}
|