-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement support for mutable variables
- Loading branch information
Showing
8 changed files
with
106 additions
and
14 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
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
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ internal enum TokenKind | |
Else, | ||
For, | ||
In, | ||
Var, | ||
Binary, | ||
Unary, | ||
Identifier, | ||
|
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 Kaleidoscope.Syntax; | ||
|
||
/// <summary> | ||
/// A variable definition expression. | ||
/// </summary> | ||
/// <param name="Name">The name of the variable being defined.</param> | ||
/// <param name="Value">The initial value of the variable.</param> | ||
/// <param name="Body">The expression in which the variable is defined.</param> | ||
/// <param name="Range">The expression's source range.</param> | ||
public sealed record VarInExpr(string Name, IExpr Value, IExpr Body, Range Range) : IExpr | ||
{ | ||
public T Accept<T>(IExprVisitor<T> visitor) | ||
{ | ||
return visitor.Visit(this); | ||
} | ||
|
||
public override string ToString() => $"var {Name} = {Value} in {Body}"; | ||
} |