-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement parsing of function expression
This allows us to parse: ```js a = function OPT_NAME() { // BODY } ``` Which will create an FunctionExpression in our AST.
- Loading branch information
1 parent
0976ee7
commit 38ce2d0
Showing
3 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace JSS.Lib.AST; | ||
|
||
// 15.2 Function Definitions, https://tc39.es/ecma262/#sec-function-definitions | ||
internal sealed class FunctionExpression : IExpression | ||
{ | ||
public FunctionExpression(string? identifier, List<Identifier> parameters, StatementList body) | ||
{ | ||
Identifier = identifier; | ||
Parameters = parameters; | ||
Body = body; | ||
} | ||
|
||
// FIXME: 15.2.6 Runtime Semantics: Evaluation, https://tc39.es/ecma262/#sec-function-definitions-runtime-semantics-evaluation | ||
|
||
public string? Identifier { get; } | ||
public IReadOnlyList<Identifier> Parameters { get; } | ||
public StatementList Body { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters