Documentation ¶
Overview ¶
The resolver package should not be used independently from the parser. It is not a complete Visitor itself, but is rather used to resolve single Nodes while parsing to ensure correct parsing of function-calls etc. Because of this you will find many r.visit(x) calls to be commented out.
Index ¶
- type Resolver
- func (*Resolver) BaseVisitor()
- func (r *Resolver) ResolveNode(node ast.Node)
- func (r *Resolver) VisitAssignStmt(stmt *ast.AssignStmt) ast.VisitResult
- func (r *Resolver) VisitBadDecl(decl *ast.BadDecl) ast.VisitResult
- func (r *Resolver) VisitBadExpr(expr *ast.BadExpr) ast.VisitResult
- func (r *Resolver) VisitBadStmt(stmt *ast.BadStmt) ast.VisitResult
- func (r *Resolver) VisitBinaryExpr(expr *ast.BinaryExpr) ast.VisitResult
- func (r *Resolver) VisitBlockStmt(stmt *ast.BlockStmt) ast.VisitResult
- func (r *Resolver) VisitBoolLit(expr *ast.BoolLit) ast.VisitResult
- func (r *Resolver) VisitBreakContinueStmt(stmt *ast.BreakContinueStmt) ast.VisitResult
- func (r *Resolver) VisitCastExpr(expr *ast.CastExpr) ast.VisitResult
- func (r *Resolver) VisitCharLit(expr *ast.CharLit) ast.VisitResult
- func (r *Resolver) VisitDeclStmt(stmt *ast.DeclStmt) ast.VisitResult
- func (r *Resolver) VisitExprStmt(stmt *ast.ExprStmt) ast.VisitResult
- func (r *Resolver) VisitFieldAccess(expr *ast.FieldAccess) ast.VisitResult
- func (r *Resolver) VisitFloatLit(expr *ast.FloatLit) ast.VisitResult
- func (r *Resolver) VisitForRangeStmt(stmt *ast.ForRangeStmt) ast.VisitResult
- func (r *Resolver) VisitForStmt(stmt *ast.ForStmt) ast.VisitResult
- func (r *Resolver) VisitFuncCall(expr *ast.FuncCall) ast.VisitResult
- func (r *Resolver) VisitFuncDecl(decl *ast.FuncDecl) ast.VisitResult
- func (r *Resolver) VisitGrouping(expr *ast.Grouping) ast.VisitResult
- func (r *Resolver) VisitIdent(expr *ast.Ident) ast.VisitResult
- func (r *Resolver) VisitIfStmt(stmt *ast.IfStmt) ast.VisitResult
- func (r *Resolver) VisitImportStmt(stmt *ast.ImportStmt) ast.VisitResult
- func (r *Resolver) VisitIndexing(expr *ast.Indexing) ast.VisitResult
- func (r *Resolver) VisitIntLit(expr *ast.IntLit) ast.VisitResult
- func (r *Resolver) VisitListLit(expr *ast.ListLit) ast.VisitResult
- func (r *Resolver) VisitReturnStmt(stmt *ast.ReturnStmt) ast.VisitResult
- func (r *Resolver) VisitStringLit(expr *ast.StringLit) ast.VisitResult
- func (r *Resolver) VisitStructDecl(decl *ast.StructDecl) ast.VisitResult
- func (r *Resolver) VisitStructLiteral(expr *ast.StructLiteral) ast.VisitResult
- func (r *Resolver) VisitTernaryExpr(expr *ast.TernaryExpr) ast.VisitResult
- func (r *Resolver) VisitUnaryExpr(expr *ast.UnaryExpr) ast.VisitResult
- func (r *Resolver) VisitVarDecl(decl *ast.VarDecl) ast.VisitResult
- func (r *Resolver) VisitWhileStmt(stmt *ast.WhileStmt) ast.VisitResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resolver ¶
type Resolver struct { ErrorHandler ddperror.Handler // function to which errors are passed CurrentTable *ast.SymbolTable // needed state, public for the parser Module *ast.Module // the module that is being resolved LoopDepth uint // for break and continue statements // contains filtered or unexported fields }
holds state to resolve the symbols of an AST and its nodes and checking if they are valid fills the ASTs SymbolTable while doing so
even though it is a visitor, it should not be used seperately from the parser all it's VisitX return values are dummy returns
TODO: add a snychronize method like in the parser to prevent unnessecary errors
func New ¶
func New(Mod *ast.Module, errorHandler ddperror.Handler, file string, panicMode *bool) (*Resolver, error)
create a new resolver to resolve the passed AST
func (*Resolver) BaseVisitor ¶
func (*Resolver) BaseVisitor()
func (*Resolver) VisitAssignStmt ¶
func (r *Resolver) VisitAssignStmt(stmt *ast.AssignStmt) ast.VisitResult
func (*Resolver) VisitBadDecl ¶
func (r *Resolver) VisitBadDecl(decl *ast.BadDecl) ast.VisitResult
if a BadDecl exists the AST is faulty
func (*Resolver) VisitBadExpr ¶
func (r *Resolver) VisitBadExpr(expr *ast.BadExpr) ast.VisitResult
if a BadExpr exists the AST is faulty
func (*Resolver) VisitBadStmt ¶
func (r *Resolver) VisitBadStmt(stmt *ast.BadStmt) ast.VisitResult
if a BadStmt exists the AST is faulty
func (*Resolver) VisitBinaryExpr ¶
func (r *Resolver) VisitBinaryExpr(expr *ast.BinaryExpr) ast.VisitResult
func (*Resolver) VisitBlockStmt ¶
func (r *Resolver) VisitBlockStmt(stmt *ast.BlockStmt) ast.VisitResult
func (*Resolver) VisitBoolLit ¶
func (r *Resolver) VisitBoolLit(expr *ast.BoolLit) ast.VisitResult
func (*Resolver) VisitBreakContinueStmt ¶
func (r *Resolver) VisitBreakContinueStmt(stmt *ast.BreakContinueStmt) ast.VisitResult
func (*Resolver) VisitCastExpr ¶
func (r *Resolver) VisitCastExpr(expr *ast.CastExpr) ast.VisitResult
func (*Resolver) VisitCharLit ¶
func (r *Resolver) VisitCharLit(expr *ast.CharLit) ast.VisitResult
func (*Resolver) VisitDeclStmt ¶
func (r *Resolver) VisitDeclStmt(stmt *ast.DeclStmt) ast.VisitResult
func (*Resolver) VisitExprStmt ¶
func (r *Resolver) VisitExprStmt(stmt *ast.ExprStmt) ast.VisitResult
func (*Resolver) VisitFieldAccess ¶
func (r *Resolver) VisitFieldAccess(expr *ast.FieldAccess) ast.VisitResult
func (*Resolver) VisitFloatLit ¶
func (r *Resolver) VisitFloatLit(expr *ast.FloatLit) ast.VisitResult
func (*Resolver) VisitForRangeStmt ¶
func (r *Resolver) VisitForRangeStmt(stmt *ast.ForRangeStmt) ast.VisitResult
func (*Resolver) VisitForStmt ¶
func (r *Resolver) VisitForStmt(stmt *ast.ForStmt) ast.VisitResult
func (*Resolver) VisitFuncCall ¶
func (r *Resolver) VisitFuncCall(expr *ast.FuncCall) ast.VisitResult
func (*Resolver) VisitFuncDecl ¶
func (r *Resolver) VisitFuncDecl(decl *ast.FuncDecl) ast.VisitResult
func (*Resolver) VisitGrouping ¶
func (r *Resolver) VisitGrouping(expr *ast.Grouping) ast.VisitResult
func (*Resolver) VisitIdent ¶
func (r *Resolver) VisitIdent(expr *ast.Ident) ast.VisitResult
func (*Resolver) VisitIfStmt ¶
func (r *Resolver) VisitIfStmt(stmt *ast.IfStmt) ast.VisitResult
func (*Resolver) VisitImportStmt ¶
func (r *Resolver) VisitImportStmt(stmt *ast.ImportStmt) ast.VisitResult
func (*Resolver) VisitIndexing ¶
func (r *Resolver) VisitIndexing(expr *ast.Indexing) ast.VisitResult
func (*Resolver) VisitIntLit ¶
func (r *Resolver) VisitIntLit(expr *ast.IntLit) ast.VisitResult
nothing to do for literals
func (*Resolver) VisitListLit ¶
func (r *Resolver) VisitListLit(expr *ast.ListLit) ast.VisitResult
func (*Resolver) VisitReturnStmt ¶
func (r *Resolver) VisitReturnStmt(stmt *ast.ReturnStmt) ast.VisitResult
func (*Resolver) VisitStringLit ¶
func (r *Resolver) VisitStringLit(expr *ast.StringLit) ast.VisitResult
func (*Resolver) VisitStructDecl ¶
func (r *Resolver) VisitStructDecl(decl *ast.StructDecl) ast.VisitResult
func (*Resolver) VisitStructLiteral ¶
func (r *Resolver) VisitStructLiteral(expr *ast.StructLiteral) ast.VisitResult
func (*Resolver) VisitTernaryExpr ¶
func (r *Resolver) VisitTernaryExpr(expr *ast.TernaryExpr) ast.VisitResult
func (*Resolver) VisitUnaryExpr ¶
func (r *Resolver) VisitUnaryExpr(expr *ast.UnaryExpr) ast.VisitResult
func (*Resolver) VisitVarDecl ¶
func (r *Resolver) VisitVarDecl(decl *ast.VarDecl) ast.VisitResult
func (*Resolver) VisitWhileStmt ¶
func (r *Resolver) VisitWhileStmt(stmt *ast.WhileStmt) ast.VisitResult