Rename Identifier to Variable
This commit is contained in:
parent
f9df52b5f9
commit
108870c731
2
AST.cs
2
AST.cs
@ -16,7 +16,7 @@ public record Field(Name Name, Expr? Value);
|
|||||||
|
|
||||||
public record BaseRecord(Expr Value, Field[] Updates);
|
public record BaseRecord(Expr Value, Field[] Updates);
|
||||||
|
|
||||||
public partial record Identifier
|
public partial record Variable
|
||||||
{
|
{
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ public interface IExprVisitor<T> {
|
|||||||
T visitLiteralExpr(Literal expr);
|
T visitLiteralExpr(Literal expr);
|
||||||
T visitUnaryExpr(Unary expr);
|
T visitUnaryExpr(Unary expr);
|
||||||
T visitIfExpr(If expr);
|
T visitIfExpr(If expr);
|
||||||
T visitIdentifierExpr(Identifier expr);
|
T visitVariableExpr(Variable expr);
|
||||||
T visitListExpr(List expr);
|
T visitListExpr(List expr);
|
||||||
T visitVariantExpr(Variant expr);
|
T visitVariantExpr(Variant expr);
|
||||||
T visitRecordExpr(Record expr);
|
T visitRecordExpr(Record expr);
|
||||||
@ -69,11 +69,11 @@ public partial record If(Expr Condition, Expr Then, Expr Else) : Expr()
|
|||||||
return visitor.visitIfExpr(this);
|
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)
|
public override T accept<T>(IExprVisitor<T> visitor)
|
||||||
{
|
{
|
||||||
return visitor.visitIdentifierExpr(this);
|
return visitor.visitVariableExpr(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public partial record List(Expr[] Elements) : Expr()
|
public partial record List(Expr[] Elements) : Expr()
|
||||||
|
@ -275,7 +275,7 @@ public class Interpreter : AST.IExprVisitor<object>
|
|||||||
return evaluate(expr.Expression);
|
return evaluate(expr.Expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object visitIdentifierExpr(AST.Identifier expr)
|
public object visitVariableExpr(AST.Variable expr)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ class Parser
|
|||||||
var ident = name();
|
var ident = name();
|
||||||
if (ident != null)
|
if (ident != null)
|
||||||
{
|
{
|
||||||
return new Identifier(ident);
|
return new Variable(ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match(TokenType.LParen))
|
if (match(TokenType.LParen))
|
||||||
|
14
Type.cs
Normal file
14
Type.cs
Normal 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();
|
||||||
|
}
|
@ -22,7 +22,7 @@ let exprTypes =
|
|||||||
[ { Type = "Expr"; Name = "Condition" }
|
[ { Type = "Expr"; Name = "Condition" }
|
||||||
{ Type = "Expr"; Name = "Then" }
|
{ Type = "Expr"; Name = "Then" }
|
||||||
{ Type = "Expr"; Name = "Else" } ] }
|
{ Type = "Expr"; Name = "Else" } ] }
|
||||||
{ Name = "Identifier"
|
{ Name = "Variable"
|
||||||
Fields = [ { Type = "Name"; Name = "Value" } ] }
|
Fields = [ { Type = "Name"; Name = "Value" } ] }
|
||||||
{ Name = "List"
|
{ Name = "List"
|
||||||
Fields = [ { Type = "Expr[]"; Name = "Elements" } ] }
|
Fields = [ { Type = "Expr[]"; Name = "Elements" } ] }
|
||||||
|
Loading…
Reference in New Issue
Block a user