Documentation ¶
Overview ¶
Generated file, do not modify Invocation: gen_ast -spec ./cmd/gen_ast/expr.spec -dest expr.go -extensions typename
Generated file, do not modify Invocation: gen_ast -spec ./cmd/gen_ast/stmt.spec -dest stmt.go
Generated file, do not modify Invocation: gen_ast -spec ./cmd/gen_ast/type.spec -dest type.go
Index ¶
- func PrintExpr(expr Expr) string
- func PrintStmts(stmts ...Stmt) string
- func PrintType(t Type) string
- type AssignmentExpr
- type BinaryExpr
- type BlockStmt
- type BoolType
- type BreakStmt
- type CallExpr
- type Callable
- type ClassStmt
- type ContinueStmt
- type Environment
- func (env *Environment) Child(t dynType) *Environment
- func (env *Environment) Debug() string
- func (env *Environment) Define(name string, value any)
- func (env *Environment) Get(name Token) any
- func (env *Environment) GetStatic(distance int, index int) any
- func (env *Environment) Set(name Token, value any)
- func (env *Environment) SetStatic(distance int, index int, value any)
- type Expr
- type ExpressionStmt
- type FunctionExpr
- type FunctionStmt
- type FunctionType
- type GetExpr
- type GroupingExpr
- type IfStmt
- type Interpreter
- func (i *Interpreter) Debug() string
- func (i *Interpreter) Interpret(stmts []Stmt) (err error)
- func (i *Interpreter) SetStdout(w io.Writer)
- func (i *Interpreter) VisitAssignmentExpr(expr *AssignmentExpr)
- func (i *Interpreter) VisitBinaryExpr(expr *BinaryExpr)
- func (i *Interpreter) VisitBlockStmt(stmt BlockStmt)
- func (i *Interpreter) VisitBreakStmt(stmt BreakStmt)
- func (i *Interpreter) VisitCallExpr(expr *CallExpr)
- func (i *Interpreter) VisitClassStmt(stmt ClassStmt)
- func (i *Interpreter) VisitContinueStmt(stmt ContinueStmt)
- func (i *Interpreter) VisitExpressionStmt(stmt ExpressionStmt)
- func (i *Interpreter) VisitFunctionExpr(expr *FunctionExpr)
- func (i *Interpreter) VisitFunctionStmt(stmt FunctionStmt)
- func (i *Interpreter) VisitGetExpr(expr *GetExpr)
- func (i *Interpreter) VisitGroupingExpr(expr *GroupingExpr)
- func (i *Interpreter) VisitIfStmt(stmt IfStmt)
- func (i *Interpreter) VisitLiteralExpr(expr *LiteralExpr)
- func (i *Interpreter) VisitLogicExpr(expr *LogicExpr)
- func (i *Interpreter) VisitLoopStmt(stmt LoopStmt)
- func (i *Interpreter) VisitPrintStmt(stmt PrintStmt)
- func (i *Interpreter) VisitReturnStmt(stmt ReturnStmt)
- func (i *Interpreter) VisitSetExpr(expr *SetExpr)
- func (i *Interpreter) VisitThisExpr(expr *ThisExpr)
- func (i *Interpreter) VisitUnaryExpr(expr *UnaryExpr)
- func (i *Interpreter) VisitVarStmt(stmt VarStmt)
- func (i *Interpreter) VisitVariableExpr(expr *VariableExpr)
- type LiteralExpr
- type LogicExpr
- type LoopStmt
- type NilType
- type NumberType
- type Parser
- type PrintStmt
- type RefType
- type Resolver
- func (r *Resolver) Resolve(stmts []Stmt) error
- func (r *Resolver) VisitAssignmentExpr(expr *AssignmentExpr)
- func (r *Resolver) VisitBinaryExpr(expr *BinaryExpr)
- func (r *Resolver) VisitBlockStmt(stmt BlockStmt)
- func (r *Resolver) VisitBreakStmt(stmt BreakStmt)
- func (r *Resolver) VisitCallExpr(expr *CallExpr)
- func (r *Resolver) VisitClassStmt(stmt ClassStmt)
- func (r *Resolver) VisitContinueStmt(stmt ContinueStmt)
- func (r *Resolver) VisitExpressionStmt(stmt ExpressionStmt)
- func (r *Resolver) VisitFunctionExpr(expr *FunctionExpr)
- func (r *Resolver) VisitFunctionStmt(stmt FunctionStmt)
- func (r *Resolver) VisitGetExpr(expr *GetExpr)
- func (r *Resolver) VisitGroupingExpr(expr *GroupingExpr)
- func (r *Resolver) VisitIfStmt(stmt IfStmt)
- func (r *Resolver) VisitLiteralExpr(expr *LiteralExpr)
- func (r *Resolver) VisitLogicExpr(expr *LogicExpr)
- func (r *Resolver) VisitLoopStmt(stmt LoopStmt)
- func (r *Resolver) VisitPrintStmt(stmt PrintStmt)
- func (r *Resolver) VisitReturnStmt(stmt ReturnStmt)
- func (r *Resolver) VisitSetExpr(expr *SetExpr)
- func (r *Resolver) VisitThisExpr(expr *ThisExpr)
- func (r *Resolver) VisitUnaryExpr(expr *UnaryExpr)
- func (r *Resolver) VisitVarStmt(stmt VarStmt)
- func (r *Resolver) VisitVariableExpr(expr *VariableExpr)
- type ReturnStmt
- type Scanner
- type SetExpr
- type Stmt
- type StringType
- type ThisExpr
- type Token
- type TokenType
- type Type
- type UnaryExpr
- type VarStmt
- type VariableExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintStmts ¶
Types ¶
type AssignmentExpr ¶
func (*AssignmentExpr) Accept ¶
func (e *AssignmentExpr) Accept(v exprVisitor)
func (*AssignmentExpr) String ¶
func (e *AssignmentExpr) String() string
func (*AssignmentExpr) TypeName ¶
func (*AssignmentExpr) TypeName() string
type BinaryExpr ¶
func (*BinaryExpr) Accept ¶
func (e *BinaryExpr) Accept(v exprVisitor)
func (*BinaryExpr) String ¶
func (e *BinaryExpr) String() string
func (*BinaryExpr) TypeName ¶
func (*BinaryExpr) TypeName() string
type ClassStmt ¶
type ClassStmt struct { Name Token Methods []FunctionStmt Vars []VarStmt StaticMethods []FunctionStmt StaticVars []VarStmt }
type ContinueStmt ¶
type ContinueStmt struct {
Keyword Token
}
func (ContinueStmt) Accept ¶
func (s ContinueStmt) Accept(v stmtVisitor)
func (ContinueStmt) String ¶
func (s ContinueStmt) String() string
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
func NewEnvironment ¶
func NewEnvironment(t dynType) *Environment
func (*Environment) Child ¶
func (env *Environment) Child(t dynType) *Environment
func (*Environment) Debug ¶
func (env *Environment) Debug() string
func (*Environment) Define ¶
func (env *Environment) Define(name string, value any)
func (*Environment) Get ¶
func (env *Environment) Get(name Token) any
func (*Environment) Set ¶
func (env *Environment) Set(name Token, value any)
type ExpressionStmt ¶
type ExpressionStmt struct {
Expression Expr
}
func (ExpressionStmt) Accept ¶
func (s ExpressionStmt) Accept(v stmtVisitor)
func (ExpressionStmt) String ¶
func (s ExpressionStmt) String() string
type FunctionExpr ¶
func (*FunctionExpr) Accept ¶
func (e *FunctionExpr) Accept(v exprVisitor)
func (*FunctionExpr) String ¶
func (e *FunctionExpr) String() string
func (*FunctionExpr) TypeName ¶
func (*FunctionExpr) TypeName() string
type FunctionStmt ¶
func (FunctionStmt) Accept ¶
func (s FunctionStmt) Accept(v stmtVisitor)
func (FunctionStmt) String ¶
func (s FunctionStmt) String() string
type FunctionType ¶
func (FunctionType) Accept ¶
func (t FunctionType) Accept(v typeVisitor)
func (FunctionType) String ¶
func (t FunctionType) String() string
type GroupingExpr ¶
type GroupingExpr struct {
Expression Expr
}
func (*GroupingExpr) Accept ¶
func (e *GroupingExpr) Accept(v exprVisitor)
func (*GroupingExpr) String ¶
func (e *GroupingExpr) String() string
func (*GroupingExpr) TypeName ¶
func (*GroupingExpr) TypeName() string
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func NewInterpreter ¶
func NewInterpreter() *Interpreter
func (*Interpreter) Debug ¶
func (i *Interpreter) Debug() string
func (*Interpreter) Interpret ¶
func (i *Interpreter) Interpret(stmts []Stmt) (err error)
func (*Interpreter) SetStdout ¶
func (i *Interpreter) SetStdout(w io.Writer)
func (*Interpreter) VisitAssignmentExpr ¶
func (i *Interpreter) VisitAssignmentExpr(expr *AssignmentExpr)
func (*Interpreter) VisitBinaryExpr ¶
func (i *Interpreter) VisitBinaryExpr(expr *BinaryExpr)
func (*Interpreter) VisitBlockStmt ¶
func (i *Interpreter) VisitBlockStmt(stmt BlockStmt)
func (*Interpreter) VisitBreakStmt ¶
func (i *Interpreter) VisitBreakStmt(stmt BreakStmt)
func (*Interpreter) VisitCallExpr ¶
func (i *Interpreter) VisitCallExpr(expr *CallExpr)
func (*Interpreter) VisitClassStmt ¶
func (i *Interpreter) VisitClassStmt(stmt ClassStmt)
func (*Interpreter) VisitContinueStmt ¶
func (i *Interpreter) VisitContinueStmt(stmt ContinueStmt)
func (*Interpreter) VisitExpressionStmt ¶
func (i *Interpreter) VisitExpressionStmt(stmt ExpressionStmt)
func (*Interpreter) VisitFunctionExpr ¶
func (i *Interpreter) VisitFunctionExpr(expr *FunctionExpr)
func (*Interpreter) VisitFunctionStmt ¶
func (i *Interpreter) VisitFunctionStmt(stmt FunctionStmt)
func (*Interpreter) VisitGetExpr ¶
func (i *Interpreter) VisitGetExpr(expr *GetExpr)
func (*Interpreter) VisitGroupingExpr ¶
func (i *Interpreter) VisitGroupingExpr(expr *GroupingExpr)
func (*Interpreter) VisitIfStmt ¶
func (i *Interpreter) VisitIfStmt(stmt IfStmt)
func (*Interpreter) VisitLiteralExpr ¶
func (i *Interpreter) VisitLiteralExpr(expr *LiteralExpr)
func (*Interpreter) VisitLogicExpr ¶
func (i *Interpreter) VisitLogicExpr(expr *LogicExpr)
func (*Interpreter) VisitLoopStmt ¶
func (i *Interpreter) VisitLoopStmt(stmt LoopStmt)
func (*Interpreter) VisitPrintStmt ¶
func (i *Interpreter) VisitPrintStmt(stmt PrintStmt)
func (*Interpreter) VisitReturnStmt ¶
func (i *Interpreter) VisitReturnStmt(stmt ReturnStmt)
func (*Interpreter) VisitSetExpr ¶
func (i *Interpreter) VisitSetExpr(expr *SetExpr)
func (*Interpreter) VisitThisExpr ¶
func (i *Interpreter) VisitThisExpr(expr *ThisExpr)
func (*Interpreter) VisitUnaryExpr ¶
func (i *Interpreter) VisitUnaryExpr(expr *UnaryExpr)
func (*Interpreter) VisitVarStmt ¶
func (i *Interpreter) VisitVarStmt(stmt VarStmt)
func (*Interpreter) VisitVariableExpr ¶
func (i *Interpreter) VisitVariableExpr(expr *VariableExpr)
type LiteralExpr ¶
func (*LiteralExpr) Accept ¶
func (e *LiteralExpr) Accept(v exprVisitor)
func (*LiteralExpr) String ¶
func (e *LiteralExpr) String() string
func (*LiteralExpr) TypeName ¶
func (*LiteralExpr) TypeName() string
type NumberType ¶
type NumberType struct {
Token Token
}
func (NumberType) Accept ¶
func (t NumberType) Accept(v typeVisitor)
func (NumberType) String ¶
func (t NumberType) String() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ParseExpression ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func NewResolver ¶
func NewResolver(interpreter *Interpreter) *Resolver
func (*Resolver) VisitAssignmentExpr ¶
func (r *Resolver) VisitAssignmentExpr(expr *AssignmentExpr)
func (*Resolver) VisitBinaryExpr ¶
func (r *Resolver) VisitBinaryExpr(expr *BinaryExpr)
func (*Resolver) VisitBlockStmt ¶
func (*Resolver) VisitBreakStmt ¶
func (*Resolver) VisitCallExpr ¶
func (*Resolver) VisitClassStmt ¶
func (*Resolver) VisitContinueStmt ¶
func (r *Resolver) VisitContinueStmt(stmt ContinueStmt)
func (*Resolver) VisitExpressionStmt ¶
func (r *Resolver) VisitExpressionStmt(stmt ExpressionStmt)
func (*Resolver) VisitFunctionExpr ¶
func (r *Resolver) VisitFunctionExpr(expr *FunctionExpr)
func (*Resolver) VisitFunctionStmt ¶
func (r *Resolver) VisitFunctionStmt(stmt FunctionStmt)
func (*Resolver) VisitGetExpr ¶
func (*Resolver) VisitGroupingExpr ¶
func (r *Resolver) VisitGroupingExpr(expr *GroupingExpr)
func (*Resolver) VisitIfStmt ¶
func (*Resolver) VisitLiteralExpr ¶
func (r *Resolver) VisitLiteralExpr(expr *LiteralExpr)
func (*Resolver) VisitLogicExpr ¶
func (*Resolver) VisitLoopStmt ¶
func (*Resolver) VisitPrintStmt ¶
func (*Resolver) VisitReturnStmt ¶
func (r *Resolver) VisitReturnStmt(stmt ReturnStmt)
func (*Resolver) VisitSetExpr ¶
func (*Resolver) VisitThisExpr ¶
func (*Resolver) VisitUnaryExpr ¶
func (*Resolver) VisitVarStmt ¶
func (*Resolver) VisitVariableExpr ¶
func (r *Resolver) VisitVariableExpr(expr *VariableExpr)
type ReturnStmt ¶
func (ReturnStmt) Accept ¶
func (s ReturnStmt) Accept(v stmtVisitor)
func (ReturnStmt) String ¶
func (s ReturnStmt) String() string
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
func NewScanner ¶
func (*Scanner) ScanTokens ¶
type StringType ¶
type StringType struct {
Token Token
}
func (StringType) Accept ¶
func (t StringType) Accept(v typeVisitor)
func (StringType) String ¶
func (t StringType) String() string
type TokenType ¶
type TokenType int
const ( // Single-character tokens. LeftParen TokenType = iota RightParen LeftBrace RightBrace Comma Dot Minus Plus Semicolon Slash Star // One or two character tokens. Bang BangEqual Equal EqualEqual Greater GreaterEqual Less LessEqual // Literals. Identifier String Number // Keywords. And Break Class Continue Else False Fun For If Nil Or Print Return Super This True Var While // Sentinel for end-of-file. EOF )
type VariableExpr ¶
type VariableExpr struct {
Name Token
}
func (*VariableExpr) Accept ¶
func (e *VariableExpr) Accept(v exprVisitor)
func (*VariableExpr) String ¶
func (e *VariableExpr) String() string
func (*VariableExpr) TypeName ¶
func (*VariableExpr) TypeName() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.