package ast
import "github.com/azin-lang/Azin/pkg/ast"
Index
- func AdjustPositions(program *Program, delta uint32)
- func ExportDebugTree(node Node, path string) error
- func PrintDebugTree(node Node)
- type AssignmentStmt
- type BadExpr
- type BadStmt
- type BinaryExpr
- type BooleanLiteral
- type CallExpr
- type CharacterLiteral
- type DeferStmt
- type EnumStmt
- type Expr
- type ExpressionStmt
- type FieldDecl
- type FloatLiteral
- type FuncStmt
- type Identifier
- type IfStmt
- type ImportCStmt
- type ImportStmt
- type IntegerLiteral
- type LoopStmt
- type MemberExpr
- type Node
- type Program
- type ReturnStmt
- type Stmt
- type StopStmt
- type StringLiteral
- type StructStmt
- type VarStmt
- type WhileStmt
Functions
func AdjustPositions
func AdjustPositions(program *Program, delta uint32)
AdjustPositions adds delta to all token positions in the program.
func ExportDebugTree
func ExportDebugTree(node Node, path string) error
func PrintDebugTree
func PrintDebugTree(node Node)
Types
type AssignmentStmt
type AssignmentStmt struct { Token token.Token // = Left Expr Value Expr }
func (*AssignmentStmt) Label
func (*AssignmentStmt) Label() string
func (*AssignmentStmt) Pos
func (a *AssignmentStmt) Pos() token.Position
func (*AssignmentStmt) TokenLiteral
func (a *AssignmentStmt) TokenLiteral() string
type BadExpr
type BadExpr struct { Token token.Token }
func (*BadExpr) Equals
func (*BadExpr) Equals(other Expr) bool
func (*BadExpr) Label
func (*BadExpr) Label() string
func (*BadExpr) Pos
func (b *BadExpr) Pos() token.Position
func (*BadExpr) TokenLiteral
func (b *BadExpr) TokenLiteral() string
func (*BadExpr) Type
func (*BadExpr) Type() *types.TypeInfo
type BadStmt
type BadStmt struct { Token token.Token }
func (*BadStmt) Label
func (*BadStmt) Label() string
func (*BadStmt) Pos
func (b *BadStmt) Pos() token.Position
func (*BadStmt) TokenLiteral
func (b *BadStmt) TokenLiteral() string
type BinaryExpr
type BinaryExpr struct { Left Expr Operator token.Token Right Expr // SemaResultType contains the result type of the binary operation, set after semantic analysis. SemaResultType *types.TypeInfo }
func (*BinaryExpr) Equals
func (b *BinaryExpr) Equals(other Expr) bool
func (*BinaryExpr) Label
func (b *BinaryExpr) Label() string
func (*BinaryExpr) Pos
func (b *BinaryExpr) Pos() token.Position
func (*BinaryExpr) TokenLiteral
func (b *BinaryExpr) TokenLiteral() string
func (*BinaryExpr) Type
func (b *BinaryExpr) Type() *types.TypeInfo
type BooleanLiteral
type BooleanLiteral struct { Token token.Token Value bool }
func (*BooleanLiteral) Equals
func (b *BooleanLiteral) Equals(other Expr) bool
func (*BooleanLiteral) Label
func (b *BooleanLiteral) Label() string
func (*BooleanLiteral) Pos
func (b *BooleanLiteral) Pos() token.Position
func (*BooleanLiteral) TokenLiteral
func (b *BooleanLiteral) TokenLiteral() string
func (*BooleanLiteral) Type
func (b *BooleanLiteral) Type() *types.TypeInfo
type CallExpr
type CallExpr struct { Callee Expr Args []Expr ResolvedName string // SemaReturnType contains the return type of the function call, set after semantic analysis. SemaReturnType *types.TypeInfo }
func (*CallExpr) Equals
func (c *CallExpr) Equals(other Expr) bool
func (*CallExpr) Label
func (c *CallExpr) Label() string
func (*CallExpr) Pos
func (c *CallExpr) Pos() token.Position
func (*CallExpr) TokenLiteral
func (c *CallExpr) TokenLiteral() string
func (*CallExpr) Type
func (c *CallExpr) Type() *types.TypeInfo
type CharacterLiteral
type CharacterLiteral struct { Token token.Token Value rune }
func (*CharacterLiteral) Equals
func (c *CharacterLiteral) Equals(other Expr) bool
func (*CharacterLiteral) Label
func (c *CharacterLiteral) Label() string
func (*CharacterLiteral) Pos
func (c *CharacterLiteral) Pos() token.Position
func (*CharacterLiteral) TokenLiteral
func (c *CharacterLiteral) TokenLiteral() string
func (*CharacterLiteral) Type
func (c *CharacterLiteral) Type() *types.TypeInfo
type DeferStmt
type DeferStmt struct { Token token.Token // defer Call Expr }
func (*DeferStmt) Label
func (*DeferStmt) Label() string
func (*DeferStmt) Pos
func (d *DeferStmt) Pos() token.Position
func (*DeferStmt) TokenLiteral
func (d *DeferStmt) TokenLiteral() string
type EnumStmt
type EnumStmt struct { Token token.Token // enum Name *Identifier Variants []*Identifier // SemaType contains the type information for the enum, set after semantic analysis. SemaType *types.TypeInfo }
func (*EnumStmt) Label
func (e *EnumStmt) Label() string
func (*EnumStmt) Pos
func (e *EnumStmt) Pos() token.Position
func (*EnumStmt) TokenLiteral
func (e *EnumStmt) TokenLiteral() string
type Expr
type Expr interface { Node Equals(other Expr) bool Type() *types.TypeInfo // contains filtered or unexported methods }
Expr represents an expression node.
type ExpressionStmt
type ExpressionStmt struct { Token token.Token Expression Expr }
func (*ExpressionStmt) Label
func (e *ExpressionStmt) Label() string
func (*ExpressionStmt) Pos
func (e *ExpressionStmt) Pos() token.Position
func (*ExpressionStmt) TokenLiteral
func (e *ExpressionStmt) TokenLiteral() string
type FieldDecl
type FieldDecl struct { Name *Identifier // SynType is the AST identifier for the type of the field. It should not be modified. SynType *Identifier Mutable bool // SemaType contains the type information for the field, set after semantic analysis. SemaType *types.TypeInfo }
func (*FieldDecl) Label
func (f *FieldDecl) Label() string
func (*FieldDecl) Pos
func (f *FieldDecl) Pos() token.Position
func (*FieldDecl) TokenLiteral
func (f *FieldDecl) TokenLiteral() string
type FloatLiteral
type FloatLiteral struct { Token token.Token Value float64 }
func (*FloatLiteral) Equals
func (f *FloatLiteral) Equals(other Expr) bool
func (*FloatLiteral) Label
func (f *FloatLiteral) Label() string
func (*FloatLiteral) Pos
func (f *FloatLiteral) Pos() token.Position
func (*FloatLiteral) TokenLiteral
func (f *FloatLiteral) TokenLiteral() string
func (*FloatLiteral) Type
func (f *FloatLiteral) Type() *types.TypeInfo
type FuncStmt
type FuncStmt struct { Token token.Token // fn Name *Identifier Params []*FieldDecl // SynReturnType is the AST identifier for the return type of the function, can be nil for void functions. It should not be modified. SynReturnType *Identifier Body []Stmt CName string // SemaReturnType is the return type of the function, set after semantic analysis. SemaReturnType *types.TypeInfo }
func (*FuncStmt) Label
func (f *FuncStmt) Label() string
func (*FuncStmt) Pos
func (f *FuncStmt) Pos() token.Position
func (*FuncStmt) TokenLiteral
func (f *FuncStmt) TokenLiteral() string
type Identifier
type Identifier struct { Token token.Token Value string // SemaType contains the type information for the identifier, set after semantic analysis. SemaType *types.TypeInfo }
func (*Identifier) Equals
func (i *Identifier) Equals(other Expr) bool
func (*Identifier) Label
func (i *Identifier) Label() string
func (*Identifier) Pos
func (i *Identifier) Pos() token.Position
func (*Identifier) TokenLiteral
func (i *Identifier) TokenLiteral() string
func (*Identifier) Type
func (i *Identifier) Type() *types.TypeInfo
type IfStmt
type IfStmt struct { Token token.Token // if Condition Expr Then []Stmt Else []Stmt }
func (*IfStmt) Label
func (*IfStmt) Label() string
func (*IfStmt) Pos
func (i *IfStmt) Pos() token.Position
func (*IfStmt) TokenLiteral
func (i *IfStmt) TokenLiteral() string
type ImportCStmt
type ImportCStmt struct { Token token.Token Path *StringLiteral }
func (*ImportCStmt) Label
func (i *ImportCStmt) Label() string
func (*ImportCStmt) Pos
func (i *ImportCStmt) Pos() token.Position
func (*ImportCStmt) TokenLiteral
func (i *ImportCStmt) TokenLiteral() string
type ImportStmt
type ImportStmt struct { Token token.Token Path *StringLiteral }
func (*ImportStmt) Label
func (i *ImportStmt) Label() string
func (*ImportStmt) Pos
func (i *ImportStmt) Pos() token.Position
func (*ImportStmt) TokenLiteral
func (i *ImportStmt) TokenLiteral() string
type IntegerLiteral
type IntegerLiteral struct { Token token.Token Value int64 }
func (*IntegerLiteral) Equals
func (i *IntegerLiteral) Equals(other Expr) bool
func (*IntegerLiteral) Label
func (i *IntegerLiteral) Label() string
func (*IntegerLiteral) Pos
func (i *IntegerLiteral) Pos() token.Position
func (*IntegerLiteral) TokenLiteral
func (i *IntegerLiteral) TokenLiteral() string
func (*IntegerLiteral) Type
func (i *IntegerLiteral) Type() *types.TypeInfo
type LoopStmt
type LoopStmt struct { Token token.Token // loop Body []Stmt }
func (*LoopStmt) Label
func (*LoopStmt) Label() string
func (*LoopStmt) Pos
func (l *LoopStmt) Pos() token.Position
func (*LoopStmt) TokenLiteral
func (l *LoopStmt) TokenLiteral() string
type MemberExpr
type MemberExpr struct { Object Expr Property *Identifier // SemaResultType contains the type of the member access, set after semantic analysis. SemaResultType *types.TypeInfo }
func (*MemberExpr) Equals
func (m *MemberExpr) Equals(other Expr) bool
func (*MemberExpr) Label
func (m *MemberExpr) Label() string
func (*MemberExpr) Pos
func (m *MemberExpr) Pos() token.Position
func (*MemberExpr) TokenLiteral
func (m *MemberExpr) TokenLiteral() string
func (*MemberExpr) Type
func (m *MemberExpr) Type() *types.TypeInfo
type Node
type Node interface { TokenLiteral() string Pos() token.Position Label() string }
Node is the interface implemented by every AST node.
type Program
type Program struct { Statements []Stmt }
Program is the root of the AST.
func (*Program) Label
func (p *Program) Label() string
func (*Program) Pos
func (p *Program) Pos() token.Position
func (*Program) TokenLiteral
func (p *Program) TokenLiteral() string
type ReturnStmt
type ReturnStmt struct { Token token.Token // return Value Expr }
func (*ReturnStmt) Label
func (*ReturnStmt) Label() string
func (*ReturnStmt) Pos
func (r *ReturnStmt) Pos() token.Position
func (*ReturnStmt) TokenLiteral
func (r *ReturnStmt) TokenLiteral() string
type Stmt
type Stmt interface { Node // contains filtered or unexported methods }
Stmt represents a statement node.
type StopStmt
type StopStmt struct { Token token.Token // stop }
func (*StopStmt) Label
func (*StopStmt) Label() string
func (*StopStmt) Pos
func (s *StopStmt) Pos() token.Position
func (*StopStmt) TokenLiteral
func (s *StopStmt) TokenLiteral() string
type StringLiteral
type StringLiteral struct { Token token.Token Value string }
func (*StringLiteral) Equals
func (s *StringLiteral) Equals(other Expr) bool
func (*StringLiteral) Label
func (s *StringLiteral) Label() string
func (*StringLiteral) Pos
func (s *StringLiteral) Pos() token.Position
func (*StringLiteral) TokenLiteral
func (s *StringLiteral) TokenLiteral() string
func (*StringLiteral) Type
func (s *StringLiteral) Type() *types.TypeInfo
type StructStmt
type StructStmt struct { Token token.Token // struct Name *Identifier Fields []*FieldDecl // SemaType contains the type information for the struct, set after semantic analysis. SemaType *types.TypeInfo }
func (*StructStmt) Label
func (s *StructStmt) Label() string
func (*StructStmt) Pos
func (s *StructStmt) Pos() token.Position
func (*StructStmt) TokenLiteral
func (s *StructStmt) TokenLiteral() string
type VarStmt
type VarStmt struct { Token token.Token // var Name *Identifier // SynType is the AST identifier for the type of the variable. It should not be modified. SynType *Identifier Value Expr Mutable bool // SemaType contains the type information for the variable, set after semantic analysis. SemaType *types.TypeInfo }
func (*VarStmt) Label
func (v *VarStmt) Label() string
func (*VarStmt) Pos
func (v *VarStmt) Pos() token.Position
func (*VarStmt) TokenLiteral
func (v *VarStmt) TokenLiteral() string
type WhileStmt
type WhileStmt struct { Token token.Token // while Condition Expr Body []Stmt }
func (*WhileStmt) Label
func (*WhileStmt) Label() string
func (*WhileStmt) Pos
func (w *WhileStmt) Pos() token.Position
func (*WhileStmt) TokenLiteral
func (w *WhileStmt) TokenLiteral() string