package ast
import "github.com/azin-lang/Azin/internal/ast"
Index
- func Print(node Node, export bool, outputPath string)
- type BinaryExpr
- type CallExpr
- type CharacterLiteral
- type Expr
- type ExpressionStmt
- type FieldDecl
- type FloatLiteral
- type FuncStmt
- type Identifier
- type IfStmt
- type ImportCStmt
- type IntegerLiteral
- type MemberExpr
- type Node
- type Program
- type ReturnStmt
- type Stmt
- type StringLiteral
- type StructStmt
- type VarStmt
Functions
func Print
func Print(node Node, export bool, outputPath string)
* prints the AST to the console or exports it to a file. * @param node the AST node to print * @param export whether to export the AST to a file * @param outputPath the path to export the AST to
Types
type BinaryExpr
type BinaryExpr struct { Left Expr Operator token.Token Right Expr }
BinaryExpr represents a binary operator expression.
func (*BinaryExpr) TokenLiteral
func (b *BinaryExpr) TokenLiteral() string
type CallExpr
type CallExpr struct { Callee Expr Args []Expr }
CallExpr represents a function call.
func (*CallExpr) TokenLiteral
func (c *CallExpr) TokenLiteral() string
type CharacterLiteral
type CharacterLiteral struct { Token token.Token Value rune }
CharacterLiteral represents a character literal.
func (*CharacterLiteral) TokenLiteral
func (c *CharacterLiteral) TokenLiteral() string
type Expr
type Expr interface { Node // contains filtered or unexported methods }
Expr represents an expression node.
type ExpressionStmt
type ExpressionStmt struct { Token token.Token Expression Expr }
ExpressionStmt represents an expression used as a statement.
Example:
printf("hello");
foo();
func (*ExpressionStmt) TokenLiteral
func (e *ExpressionStmt) TokenLiteral() string
type FieldDecl
type FieldDecl struct { Name *Identifier Type *Identifier }
FieldDecl represents either a parameter declaration or a struct field declaration.
func (*FieldDecl) TokenLiteral
func (f *FieldDecl) TokenLiteral() string
type FloatLiteral
type FloatLiteral struct { Token token.Token Value float64 }
FloatLiteral represents a floating point literal.
func (*FloatLiteral) TokenLiteral
func (i *FloatLiteral) TokenLiteral() string
type FuncStmt
type FuncStmt struct { Token token.Token // fn Name *Identifier Params []*FieldDecl ReturnType *Identifier Body []Stmt }
FuncStmt represents a function declaration.
func (*FuncStmt) TokenLiteral
func (f *FuncStmt) TokenLiteral() string
type Identifier
type Identifier struct { Token token.Token Value string }
Identifier represents an identifier.
func (*Identifier) TokenLiteral
func (i *Identifier) TokenLiteral() string
type IfStmt
type IfStmt struct { Token token.Token // if Condition Expr Then []Stmt Else []Stmt }
IfStmt represents an if/else statement.
func (*IfStmt) TokenLiteral
func (i *IfStmt) TokenLiteral() string
type ImportCStmt
type ImportCStmt struct { Token token.Token Path *StringLiteral }
ImportStmt represents an import statement.
func (*ImportCStmt) TokenLiteral
func (i *ImportCStmt) TokenLiteral() string
type IntegerLiteral
type IntegerLiteral struct { Token token.Token Value int64 }
IntegerLiteral represents an integer literal.
func (*IntegerLiteral) TokenLiteral
func (i *IntegerLiteral) TokenLiteral() string
type MemberExpr
type MemberExpr struct { Object Expr Property *Identifier }
MemberExpr represents a member access expression.
Example:
person.name
func (*MemberExpr) TokenLiteral
func (m *MemberExpr) TokenLiteral() string
type Node
type Node interface { TokenLiteral() 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) TokenLiteral
func (p *Program) TokenLiteral() string
type ReturnStmt
type ReturnStmt struct { Token token.Token // return Value Expr }
ReturnStmt represents a return statement.
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 StringLiteral
type StringLiteral struct { Token token.Token Value string }
StringLiteral represents a string literal.
func (*StringLiteral) TokenLiteral
func (s *StringLiteral) TokenLiteral() string
type StructStmt
type StructStmt struct { Token token.Token // struct Name *Identifier Fields []*FieldDecl }
StructStmt represents a struct declaration.
func (*StructStmt) TokenLiteral
func (s *StructStmt) TokenLiteral() string
type VarStmt
type VarStmt struct { Token token.Token // var Name *Identifier Type *Identifier Value Expr Mutable bool }
func (*VarStmt) TokenLiteral
func (v *VarStmt) TokenLiteral() string