From 581627dc65fda5ba2ba142141ce896524df2deac Mon Sep 17 00:00:00 2001 From: "W. Cho" Date: Thu, 21 Dec 2023 15:30:02 +0900 Subject: [PATCH] add call syntax node --- src/evaluator/index.ts | 3 ++- src/parser/syntax-tree/expression/index.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/evaluator/index.ts b/src/evaluator/index.ts index 5533125..a1f891c 100644 --- a/src/evaluator/index.ts +++ b/src/evaluator/index.ts @@ -176,7 +176,8 @@ export default class Evaluator { return value; } - const exhaustiveCheck: never = node; + // TODO: uncomment + // const exhaustiveCheck: never = node; } } diff --git a/src/parser/syntax-tree/expression/index.ts b/src/parser/syntax-tree/expression/index.ts index e73c6a3..e5ea74d 100644 --- a/src/parser/syntax-tree/expression/index.ts +++ b/src/parser/syntax-tree/expression/index.ts @@ -8,6 +8,7 @@ export type Expression = PrefixExpression | InfixExpression | FunctionExpression | + Call | Assignment; export interface Identifier { @@ -49,6 +50,12 @@ export interface FunctionExpression { body: Block; } +export interface Call { + type: "call"; + functionToCall: Identifier | FunctionExpression; + callArguments: Expression[]; +} + export interface Assignment { type: "assignment"; left: Identifier; @@ -94,6 +101,12 @@ export const makeFunctionExpression = (body: FunctionExpression["body"], paramet body, }); +export const makeCall = (functionToCall: Call["functionToCall"], callArguments: Call["callArguments"]): Call => ({ + type: "call", + functionToCall, + callArguments, +}); + export const makeAssignment = (left: Assignment["left"], right: Assignment["right"]): Assignment => ({ type: "assignment", left,