about summary refs log tree commit diff
path: root/pkg/lang/ast/stmt.go
blob: 8a538f2362cb136ca2ca6ca2b18f604bd2dddf7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package ast

import "jinx/pkg/libs/source"

type StmtKind int

const (
	StmtKindEmpty StmtKind = iota
	StmtKindUse
	StmtKindFnDecl
	StmtKindTypeDecl
	StmtKindVarDecl
	StmtKindIf
	StmtKindForCond
	StmtKindForIn
	StmtKindTry
	StmtKindReturn
	StmtKindContinue
	StmtKindBreak
	StmtKindThrow
	StmtKindExpr
)

type Stmt StmtT[any]

type StmtT[T any] struct {
	At    source.Loc
	Kind  StmtKind
	Value T
}

type StmtUse struct {
	Globals []IdentNode
	Modules []IdentNode
	Author  IdentNode
}

type StmtFnDecl struct {
	Name IdentNode
	Args []IdentNode
	Body BlockNode
}

type StmtTypeDecl struct {}

type StmtVarDecl struct {
	Name  IdentNode
	Value Expr
}

type StmtIf struct {
	Conds []CondNode
}

type StmtForCond struct {
	Cond Expr
	Do   BlockNode
}

type StmtForIn struct {
	Name       IdentNode
	Collection Expr
	Do         BlockNode
}

type StmtTry struct {
	Try         BlockNode
	CatchedName IdentNode
	Catch       BlockNode
	Finally     BlockNode
}

type StmtReturn struct {
	Value Expr
}

type StmtContinue struct{}

type StmtBreak struct{}

type StmtThrow struct {
	Value Expr
}

type StmtExpr struct {
	Value Expr
}

type StmtEmpty struct{}