53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
|
////////////////////////////////////////////////////////////
|
||
|
// THIS FILE IS GENERATED. //
|
||
|
// DO NOT EDIT. //
|
||
|
////////////////////////////////////////////////////////////
|
||
|
|
||
|
using System;
|
||
|
namespace Finn.AST;
|
||
|
|
||
|
public abstract class Expr {
|
||
|
public abstract T accept<T>(IVisitor<T> visitor);
|
||
|
}
|
||
|
public interface IVisitor<T> {
|
||
|
T visitBinaryExpr(Binary expr);
|
||
|
T visitGroupingExpr(Grouping expr);
|
||
|
T visitLiteralExpr(Literal expr);
|
||
|
T visitUnaryExpr(Unary expr);
|
||
|
}
|
||
|
public class Binary : Expr
|
||
|
{
|
||
|
public required Expr Left { get; init; }
|
||
|
public required Token Op { get; init; }
|
||
|
public required Expr Right { get; init; }
|
||
|
public override T accept<T>(IVisitor<T> visitor)
|
||
|
{
|
||
|
return visitor.visitBinaryExpr(this);
|
||
|
}
|
||
|
}
|
||
|
public class Grouping : Expr
|
||
|
{
|
||
|
public required Expr Expression { get; init; }
|
||
|
public override T accept<T>(IVisitor<T> visitor)
|
||
|
{
|
||
|
return visitor.visitGroupingExpr(this);
|
||
|
}
|
||
|
}
|
||
|
public class Literal : Expr
|
||
|
{
|
||
|
public required System.Object Value { get; init; }
|
||
|
public override T accept<T>(IVisitor<T> visitor)
|
||
|
{
|
||
|
return visitor.visitLiteralExpr(this);
|
||
|
}
|
||
|
}
|
||
|
public class Unary : Expr
|
||
|
{
|
||
|
public required Token Op { get; init; }
|
||
|
public required Expr Right { get; init; }
|
||
|
public override T accept<T>(IVisitor<T> visitor)
|
||
|
{
|
||
|
return visitor.visitUnaryExpr(this);
|
||
|
}
|
||
|
}
|