123456789101112131415161718192021 |
- import * as AST from '../ast';
- import Env, { EnvError } from '../env';
-
- export class Application {
- public name: AST.Literal;
- public arguments: AST.Node[];
-
- public constructor(name: AST.Literal, args: AST.Node[]) {
- this.name = name;
- this.arguments = args;
- }
-
- public compile(env: Env, opts: AST.Opts): string | EnvError {
- const wordSpacer = opts.prettyPrint ? ' ' : '';
- const [lParen, rParen, comma] = ['(', ')', ','];
- const compiledArguments = this.arguments
- .map((arg) => arg.compile(env, opts))
- .join(`${comma}${wordSpacer}`);
- return `${this.name.value.value}${lParen}${compiledArguments}${rParen}`;
- }
- }
|