Rename Identifier to Variable

This commit is contained in:
Brandon Dyck 2023-07-07 21:29:17 -06:00
parent f9df52b5f9
commit 108870c731
6 changed files with 21 additions and 7 deletions

2
AST.cs
View File

@ -16,7 +16,7 @@ public record Field(Name Name, Expr? Value);
public record BaseRecord(Expr Value, Field[] Updates);
public partial record Identifier
public partial record Variable
{
public override string ToString()
{

View File

@ -17,7 +17,7 @@ public interface IExprVisitor<T> {
T visitLiteralExpr(Literal expr);
T visitUnaryExpr(Unary expr);
T visitIfExpr(If expr);
T visitIdentifierExpr(Identifier expr);
T visitVariableExpr(Variable expr);
T visitListExpr(List expr);
T visitVariantExpr(Variant expr);
T visitRecordExpr(Record expr);
@ -69,11 +69,11 @@ public partial record If(Expr Condition, Expr Then, Expr Else) : Expr()
return visitor.visitIfExpr(this);
}
}
public partial record Identifier(Name Value) : Expr()
public partial record Variable(Name Value) : Expr()
{
public override T accept<T>(IExprVisitor<T> visitor)
{
return visitor.visitIdentifierExpr(this);
return visitor.visitVariableExpr(this);
}
}
public partial record List(Expr[] Elements) : Expr()

View File

@ -275,7 +275,7 @@ public class Interpreter : AST.IExprVisitor<object>
return evaluate(expr.Expression);
}
public object visitIdentifierExpr(AST.Identifier expr)
public object visitVariableExpr(AST.Variable expr)
{
throw new System.NotImplementedException();
}

View File

@ -396,7 +396,7 @@ class Parser
var ident = name();
if (ident != null)
{
return new Identifier(ident);
return new Variable(ident);
}
if (match(TokenType.LParen))

14
Type.cs Normal file
View File

@ -0,0 +1,14 @@
namespace Finn.Types;
public record Field(string Name, Type Type);
public record Row(Field[] Fields);
public abstract record Type()
{
public record Number() : Type();
public record String() : Type();
public record Param(int Name) : Type();
public record List(Type T) : Type();
public record Record(Row Row) : Type();
public record Variant(Row Row) : Type();
public record Function(Type[] Params) : Type();
}

View File

@ -22,7 +22,7 @@ let exprTypes =
[ { Type = "Expr"; Name = "Condition" }
{ Type = "Expr"; Name = "Then" }
{ Type = "Expr"; Name = "Else" } ] }
{ Name = "Identifier"
{ Name = "Variable"
Fields = [ { Type = "Name"; Name = "Value" } ] }
{ Name = "List"
Fields = [ { Type = "Expr[]"; Name = "Elements" } ] }