235 lines
3 KiB
Go
235 lines
3 KiB
Go
package lang
|
|
|
|
type Program struct {
|
|
PackagePath string
|
|
Imports []ImportDecl
|
|
Interfaces []InterfaceDecl
|
|
Classes []ClassDecl
|
|
Workers []WorkerDecl
|
|
Functions []FunctionDecl
|
|
}
|
|
|
|
type ImportDecl struct {
|
|
Alias string
|
|
Path string
|
|
}
|
|
|
|
type InterfaceDecl struct {
|
|
Name string
|
|
Methods []FunctionSignature
|
|
}
|
|
|
|
type ClassDecl struct {
|
|
Name string
|
|
Fields []FieldDecl
|
|
Parents []string
|
|
Methods []FunctionDecl
|
|
}
|
|
|
|
type WorkerDecl struct {
|
|
Name string
|
|
Fields []WorkerFieldDecl
|
|
Methods []FunctionDecl
|
|
}
|
|
|
|
type WorkerFieldDecl struct {
|
|
Mutable bool
|
|
Name string
|
|
Type string
|
|
Value Expr
|
|
}
|
|
|
|
type FieldDecl struct {
|
|
Mutable bool
|
|
Name string
|
|
Type string
|
|
}
|
|
|
|
type FunctionSignature struct {
|
|
Name string
|
|
Params []Param
|
|
ReturnType string
|
|
}
|
|
|
|
type FunctionDecl struct {
|
|
Name string
|
|
Params []Param
|
|
ReturnType string
|
|
Body []Stmt
|
|
}
|
|
|
|
type Param struct {
|
|
Name string
|
|
Type string
|
|
}
|
|
|
|
type Stmt interface {
|
|
stmtNode()
|
|
}
|
|
|
|
type Expr interface {
|
|
exprNode()
|
|
}
|
|
|
|
type VarDecl struct {
|
|
Mutable bool
|
|
Name string
|
|
Type string
|
|
Value Expr
|
|
}
|
|
|
|
func (VarDecl) stmtNode() {}
|
|
|
|
type MultiVarDecl struct {
|
|
Mutable bool
|
|
Names []string
|
|
Value Expr
|
|
}
|
|
|
|
func (MultiVarDecl) stmtNode() {}
|
|
|
|
type AssignStmt struct {
|
|
Name string
|
|
Value Expr
|
|
}
|
|
|
|
func (AssignStmt) stmtNode() {}
|
|
|
|
type AddAssignStmt struct {
|
|
Name string
|
|
Value Expr
|
|
}
|
|
|
|
func (AddAssignStmt) stmtNode() {}
|
|
|
|
type MultiAssignStmt struct {
|
|
Names []string
|
|
Value Expr
|
|
}
|
|
|
|
func (MultiAssignStmt) stmtNode() {}
|
|
|
|
type ReturnStmt struct {
|
|
Value Expr
|
|
}
|
|
|
|
func (ReturnStmt) stmtNode() {}
|
|
|
|
type ThrowStmt struct {
|
|
Value Expr
|
|
}
|
|
|
|
func (ThrowStmt) stmtNode() {}
|
|
|
|
type GoStmt struct {
|
|
Value Expr
|
|
}
|
|
|
|
func (GoStmt) stmtNode() {}
|
|
|
|
type ExprStmt struct {
|
|
Value Expr
|
|
}
|
|
|
|
func (ExprStmt) stmtNode() {}
|
|
|
|
type IfStmt struct {
|
|
Cond Expr
|
|
Then []Stmt
|
|
Else []Stmt
|
|
}
|
|
|
|
func (IfStmt) stmtNode() {}
|
|
|
|
type WhileStmt struct {
|
|
Cond Expr
|
|
Body []Stmt
|
|
}
|
|
|
|
func (WhileStmt) stmtNode() {}
|
|
|
|
type TryCatchStmt struct {
|
|
TryBody []Stmt
|
|
CatchName string
|
|
CatchType string
|
|
CatchBody []Stmt
|
|
}
|
|
|
|
func (TryCatchStmt) stmtNode() {}
|
|
|
|
type SelectStmt struct {
|
|
Cases []SelectCase
|
|
}
|
|
|
|
func (SelectStmt) stmtNode() {}
|
|
|
|
type SelectCase struct {
|
|
Source Expr
|
|
Body []Stmt
|
|
}
|
|
|
|
type IdentExpr struct {
|
|
Name string
|
|
}
|
|
|
|
func (IdentExpr) exprNode() {}
|
|
|
|
type IntExpr struct {
|
|
Value string
|
|
}
|
|
|
|
func (IntExpr) exprNode() {}
|
|
|
|
type StringExpr struct {
|
|
Value string
|
|
}
|
|
|
|
func (StringExpr) exprNode() {}
|
|
|
|
type BoolExpr struct {
|
|
Value bool
|
|
}
|
|
|
|
func (BoolExpr) exprNode() {}
|
|
|
|
type NullExpr struct{}
|
|
|
|
func (NullExpr) exprNode() {}
|
|
|
|
type UnaryExpr struct {
|
|
Op string
|
|
Value Expr
|
|
}
|
|
|
|
func (UnaryExpr) exprNode() {}
|
|
|
|
type BinaryExpr struct {
|
|
Left Expr
|
|
Op string
|
|
Right Expr
|
|
}
|
|
|
|
func (BinaryExpr) exprNode() {}
|
|
|
|
type CallExpr struct {
|
|
Callee Expr
|
|
Args []Expr
|
|
TypeArgs []string
|
|
}
|
|
|
|
func (CallExpr) exprNode() {}
|
|
|
|
type SelectorExpr struct {
|
|
Receiver Expr
|
|
Name string
|
|
}
|
|
|
|
func (SelectorExpr) exprNode() {}
|
|
|
|
type LambdaExpr struct {
|
|
Params []Param
|
|
ImplicitIt bool
|
|
Body []Stmt
|
|
}
|
|
|
|
func (LambdaExpr) exprNode() {}
|