Skip to content

Commit

Permalink
add call syntax node
Browse files Browse the repository at this point in the history
  • Loading branch information
wcho21 committed Dec 21, 2023
1 parent b567083 commit 581627d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/evaluator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ export default class Evaluator {
return value;
}

const exhaustiveCheck: never = node;
// TODO: uncomment
// const exhaustiveCheck: never = node;
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/parser/syntax-tree/expression/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type Expression =
PrefixExpression |
InfixExpression |
FunctionExpression |
Call |
Assignment;

export interface Identifier {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 581627d

Please sign in to comment.