From 5267c0e8653b431cfd2c06212cdba4f22225bd02 Mon Sep 17 00:00:00 2001 From: Mel Date: Thu, 21 Apr 2022 03:18:46 +0200 Subject: Do not force generics for Expr and Stmt --- pkg/lang/ast/stmt.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'pkg/lang/ast/stmt.go') diff --git a/pkg/lang/ast/stmt.go b/pkg/lang/ast/stmt.go index e924f8c..4f24cc5 100644 --- a/pkg/lang/ast/stmt.go +++ b/pkg/lang/ast/stmt.go @@ -5,7 +5,8 @@ import "jinx/pkg/lang/scanner/token" type StmtKind int const ( - StmtKindUse StmtKind = iota + StmtKindEmpty StmtKind = iota + StmtKindUse StmtKindFnDecl StmtKindObjectDecl StmtKindVarDecl @@ -18,7 +19,9 @@ const ( StmtKindExpr ) -type Stmt[T any] struct { +type Stmt StmtT[any] + +type StmtT[T any] struct { At token.Loc Kind StmtKind Value T @@ -40,11 +43,11 @@ type StmtObjectDecl struct{} type StmtVarDecl struct { Name IdentNode - Value Expr[any] + Value Expr } type StmtIf struct { - Cond Expr[any] + Cond Expr Then BlockNode Elifs []CondNode Else BlockNode @@ -58,7 +61,7 @@ type StmtTry struct { } type StmtReturn struct { - Value Expr[any] + Value Expr } type StmtContinue struct{} @@ -66,9 +69,11 @@ type StmtContinue struct{} type StmtBreak struct{} type StmtThrow struct { - Value Expr[any] + Value Expr } type StmtExpr struct { - Value Expr[any] + Value Expr } + +type StmtEmpty struct{} -- cgit 1.4.1