358 lines
5.1 KiB
Go
358 lines
5.1 KiB
Go
package lang
|
|
|
|
type Program struct {
|
|
PackagePath string
|
|
Imports []ImportDecl
|
|
Interfaces []InterfaceDecl
|
|
Enums []EnumDecl
|
|
Classes []ClassDecl
|
|
Functions []FunctionDecl
|
|
Embeds []EmbedDecl
|
|
}
|
|
|
|
type EmbedDecl struct {
|
|
Path, Name, Type string
|
|
TypeRef TypeRef
|
|
}
|
|
|
|
type EnumDecl struct {
|
|
Name string
|
|
Variants []EnumVariant
|
|
String bool
|
|
}
|
|
type EnumVariant struct {
|
|
Name string
|
|
PayloadTypes []string
|
|
PayloadRefs []TypeRef
|
|
StringValue string
|
|
}
|
|
|
|
type ImportDecl struct {
|
|
Alias string
|
|
Path string
|
|
}
|
|
|
|
type InterfaceDecl struct {
|
|
Name string
|
|
Methods []FunctionSignature
|
|
}
|
|
|
|
type ClassDecl struct {
|
|
Name string
|
|
TypeParams []string
|
|
Data bool
|
|
JSONNaming string
|
|
Table string
|
|
Fields []FieldDecl
|
|
Parents []string
|
|
Methods []FunctionDecl
|
|
}
|
|
|
|
type FieldDecl struct {
|
|
Mutable bool
|
|
Private bool
|
|
Name string
|
|
Type string
|
|
TypeRef TypeRef
|
|
Column string
|
|
ID bool
|
|
Generated bool
|
|
}
|
|
|
|
type FunctionSignature struct {
|
|
Name string
|
|
TypeParams []string
|
|
Params []Param
|
|
ReturnType string
|
|
ReturnRef TypeRef
|
|
ReturnExplicit bool
|
|
}
|
|
|
|
type FunctionDecl struct {
|
|
Name string
|
|
TypeParams []string
|
|
Params []Param
|
|
ReturnType string
|
|
ReturnRef TypeRef
|
|
ReturnExplicit bool
|
|
Body []Stmt
|
|
ExpressionBody Expr
|
|
InferReturn bool
|
|
}
|
|
|
|
type Param struct {
|
|
Name string
|
|
Type string
|
|
TypeRef TypeRef
|
|
}
|
|
|
|
type Stmt interface {
|
|
stmtNode()
|
|
}
|
|
|
|
type Expr interface {
|
|
exprNode()
|
|
}
|
|
|
|
type VarDecl struct {
|
|
Mutable bool
|
|
Name string
|
|
Pos int
|
|
Type string
|
|
TypeRef TypeRef
|
|
Value Expr
|
|
}
|
|
|
|
func (VarDecl) stmtNode() {}
|
|
|
|
type MultiVarDecl struct {
|
|
Mutable bool
|
|
Names []string
|
|
Value Expr
|
|
}
|
|
|
|
func (MultiVarDecl) stmtNode() {}
|
|
|
|
type AssignStmt struct {
|
|
Name string
|
|
Pos int
|
|
Value Expr
|
|
}
|
|
|
|
func (AssignStmt) stmtNode() {}
|
|
|
|
type AddAssignStmt struct {
|
|
Name string
|
|
Pos int
|
|
Value Expr
|
|
}
|
|
|
|
func (AddAssignStmt) stmtNode() {}
|
|
|
|
type MultiAssignStmt struct {
|
|
Names []string
|
|
Positions []int
|
|
Value Expr
|
|
}
|
|
|
|
func (MultiAssignStmt) stmtNode() {}
|
|
|
|
type FieldAssignStmt struct {
|
|
Target SelectorExpr
|
|
Value Expr
|
|
}
|
|
|
|
func (FieldAssignStmt) stmtNode() {}
|
|
|
|
type ReturnStmt struct {
|
|
Value Expr
|
|
}
|
|
|
|
func (ReturnStmt) stmtNode() {}
|
|
|
|
type ThrowStmt struct {
|
|
Value Expr
|
|
}
|
|
|
|
func (ThrowStmt) stmtNode() {}
|
|
|
|
type DeferStmt struct {
|
|
Value Expr
|
|
}
|
|
|
|
func (DeferStmt) 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 ForEachStmt struct {
|
|
Name string
|
|
Source Expr
|
|
Body []Stmt
|
|
}
|
|
|
|
func (ForEachStmt) stmtNode() {}
|
|
|
|
type TryCatchStmt struct {
|
|
TryBody []Stmt
|
|
CatchName string
|
|
CatchType string
|
|
CatchRef TypeRef
|
|
CatchBody []Stmt
|
|
}
|
|
|
|
func (TryCatchStmt) stmtNode() {}
|
|
|
|
type MatchStmt struct {
|
|
Value Expr
|
|
Cases []MatchCase
|
|
}
|
|
|
|
func (MatchStmt) stmtNode() {}
|
|
|
|
type MatchCase struct {
|
|
EnumName, VariantName string
|
|
Bindings []string
|
|
Body []Stmt
|
|
}
|
|
|
|
type MatchExpr struct {
|
|
Meta ExprMeta
|
|
Value Expr
|
|
Cases []MatchExprCase
|
|
}
|
|
|
|
func (MatchExpr) exprNode() {}
|
|
|
|
type MatchExprCase struct {
|
|
EnumName, VariantName string
|
|
Bindings []string
|
|
Value Expr
|
|
}
|
|
|
|
type IdentExpr struct {
|
|
Meta ExprMeta
|
|
Name string
|
|
Pos int
|
|
}
|
|
|
|
func (IdentExpr) exprNode() {}
|
|
|
|
type IntExpr struct {
|
|
Meta ExprMeta
|
|
Value string
|
|
}
|
|
|
|
func (IntExpr) exprNode() {}
|
|
|
|
type FloatExpr struct {
|
|
Meta ExprMeta
|
|
Value string
|
|
}
|
|
|
|
func (FloatExpr) exprNode() {}
|
|
|
|
type StringExpr struct {
|
|
Meta ExprMeta
|
|
Value string
|
|
}
|
|
|
|
func (StringExpr) exprNode() {}
|
|
|
|
type BoolExpr struct {
|
|
Meta ExprMeta
|
|
Value bool
|
|
}
|
|
|
|
func (BoolExpr) exprNode() {}
|
|
|
|
type NullExpr struct{ Meta ExprMeta }
|
|
|
|
func (NullExpr) exprNode() {}
|
|
|
|
type UnaryExpr struct {
|
|
Meta ExprMeta
|
|
Op string
|
|
Value Expr
|
|
}
|
|
|
|
func (UnaryExpr) exprNode() {}
|
|
|
|
type BinaryExpr struct {
|
|
Meta ExprMeta
|
|
Left Expr
|
|
Op string
|
|
Right Expr
|
|
}
|
|
|
|
func (BinaryExpr) exprNode() {}
|
|
|
|
type CallExpr struct {
|
|
Meta ExprMeta
|
|
Callee Expr
|
|
Args []Expr
|
|
TypeArgs []string
|
|
NamedArgs []NamedArg
|
|
}
|
|
|
|
type NamedArg struct {
|
|
Name string
|
|
Value Expr
|
|
}
|
|
|
|
func (CallExpr) exprNode() {}
|
|
|
|
type SelectorExpr struct {
|
|
Meta ExprMeta
|
|
Receiver Expr
|
|
Name string
|
|
NamePos int
|
|
}
|
|
|
|
func (SelectorExpr) exprNode() {}
|
|
|
|
type SafeSelectorExpr struct {
|
|
Meta ExprMeta
|
|
Receiver Expr
|
|
Name string
|
|
NamePos int
|
|
}
|
|
|
|
func (SafeSelectorExpr) exprNode() {}
|
|
|
|
type NonNullExpr struct {
|
|
Meta ExprMeta
|
|
Value Expr
|
|
}
|
|
|
|
func (NonNullExpr) exprNode() {}
|
|
|
|
type TryExpr struct {
|
|
Meta ExprMeta
|
|
Value Expr
|
|
}
|
|
|
|
func (TryExpr) exprNode() {}
|
|
|
|
type IndexExpr struct {
|
|
Meta ExprMeta
|
|
Receiver Expr
|
|
Index Expr
|
|
}
|
|
|
|
func (IndexExpr) exprNode() {}
|
|
|
|
type EnumVariantExpr struct {
|
|
Meta ExprMeta
|
|
EnumName, VariantName string
|
|
Values []Expr
|
|
}
|
|
|
|
func (EnumVariantExpr) exprNode() {}
|
|
|
|
type LambdaExpr struct {
|
|
Meta ExprMeta
|
|
Params []Param
|
|
ImplicitIt bool
|
|
Body []Stmt
|
|
}
|
|
|
|
func (LambdaExpr) exprNode() {}
|