import {Command} from "./command.js"; import {LexInput} from "../lexer.js"; import {StrVM} from "../vm.js"; import {Awaitable} from "../../util/types.js"; export class Abs extends Command<{}> { attemptParse(): Awaitable<{}> { return {} } getDisplayName(): string { return 'abs' } isParseCandidate(token: LexInput): boolean { return this.isKeyword(token, 'abs') } async execute(vm: StrVM): Promise { return vm.replaceContextMatchingTerm({ int: sub => Math.abs(sub), }) } }