Documentation
¶
Index ¶
- func IsExternFunc(fun *FuncDecl) bool
- func IsForwardDecl(fun *FuncDecl) bool
- func IsGeneric(decl Declaration) bool
- func IsGenericInstantiation(fun *FuncDecl) bool
- func IsGlobalScope(table SymbolTable) bool
- func IsOperatorOverload(fun *FuncDecl) bool
- func IsTypeDecl(decl Declaration) (ddptypes.Type, bool)
- func IsVarConstDecl(decl Declaration) bool
- func IterateImportedDecls(imprt *ImportStmt, ...)
- func IterateModuleImports(module *Module, fun func(*Module))
- func TrimStringLit(lit *token.Token) string
- func VisitModule(module *Module, visitor Visitor)
- func VisitModuleRec(module *Module, visitor Visitor)
- func VisitNode(visitor Visitor, node Node, currentScope SymbolTable)
- type Alias
- type AliasTrie
- type Annotator
- type AssignStmt
- type AssignStmtVisitor
- type AssignStmtVisitorFunc
- type Assigneable
- type Ast
- func (ast *Ast) AddAttachement(node Node, attachment MetadataAttachment)
- func (ast *Ast) GetMetadata(node Node) (Metadata, bool)
- func (ast *Ast) GetMetadataByKind(node Node, kind MetadataKind) (MetadataAttachment, bool)
- func (ast *Ast) Print()
- func (ast *Ast) RemoveAttachment(node Node, kind MetadataKind)
- func (ast *Ast) String() string
- type BadDecl
- func (decl *BadDecl) Accept(visitor FullVisitor) VisitResult
- func (decl *BadDecl) Comment() *token.Token
- func (decl *BadDecl) GetRange() token.Range
- func (decl *BadDecl) Module() *Module
- func (decl *BadDecl) Name() string
- func (decl *BadDecl) Public() bool
- func (decl *BadDecl) String() string
- func (decl *BadDecl) Token() token.Token
- type BadDeclVisitor
- type BadDeclVisitorFunc
- type BadExpr
- type BadExprVisitor
- type BadExprVisitorFunc
- type BadStmt
- type BadStmtVisitor
- type BadStmtVisitorFunc
- type BaseVisitor
- type BasicSymbolTable
- type BinaryExpr
- type BinaryExprVisitor
- type BinaryExprVisitorFunc
- type BinaryOperator
- type BlockStmt
- type BlockStmtVisitor
- type BlockStmtVisitorFunc
- type BoolLit
- type BoolLitVisitor
- type BoolLitVisitorFunc
- type BreakContinueStmt
- type BreakContinueStmtVisitor
- type BreakContinueStmtVisitorFunc
- type CastAssigneable
- type CastAssigneableVisitor
- type CastAssigneableVisitorFunc
- type CastExpr
- type CastExprVisitor
- type CastExprVisitorFunc
- type CastOperator
- type CharLit
- type CharLitVisitor
- type CharLitVisitorFunc
- type ConditionalVisitor
- type ConstDecl
- func (decl *ConstDecl) Accept(visitor FullVisitor) VisitResult
- func (decl *ConstDecl) Comment() *token.Token
- func (decl *ConstDecl) GetRange() token.Range
- func (decl *ConstDecl) Module() *Module
- func (decl *ConstDecl) Name() string
- func (decl *ConstDecl) Public() bool
- func (decl *ConstDecl) String() string
- func (decl *ConstDecl) Token() token.Token
- type ConstDeclVisitor
- type ConstDeclVisitorFunc
- type DeclStmt
- type DeclStmtVisitor
- type DeclStmtVisitorFunc
- type Declaration
- type ExprStmt
- type ExprStmtVisitor
- type ExprStmtVisitorFunc
- type Expression
- type FieldAccess
- type FieldAccessVisitor
- type FieldAccessVisitorFunc
- type FloatLit
- type FloatLitVisitor
- type FloatLitVisitorFunc
- type ForRangeStmt
- type ForRangeStmtVisitor
- type ForRangeStmtVisitorFunc
- type ForStmt
- type ForStmtVisitor
- type ForStmtVisitorFunc
- type FullVisitor
- type FuncAlias
- type FuncCall
- type FuncCallVisitor
- type FuncCallVisitorFunc
- type FuncDecl
- func (decl *FuncDecl) Accept(visitor FullVisitor) VisitResult
- func (decl *FuncDecl) Comment() *token.Token
- func (decl *FuncDecl) GetRange() token.Range
- func (decl *FuncDecl) Module() *Module
- func (decl *FuncDecl) Name() string
- func (decl *FuncDecl) Public() bool
- func (decl *FuncDecl) String() string
- func (decl *FuncDecl) Token() token.Token
- type FuncDeclVisitor
- type FuncDeclVisitorFunc
- type FuncDef
- type FuncDefVisitor
- type FuncDefVisitorFunc
- type GenericContext
- type GenericFuncInfo
- type GenericInstantiationInfo
- type Grouping
- type GroupingVisitor
- type GroupingVisitorFunc
- type Ident
- type IdentVisitor
- type IdentVisitorFunc
- type IfStmt
- type IfStmtVisitor
- type IfStmtVisitorFunc
- type ImportStmt
- type ImportStmtVisitor
- type ImportStmtVisitorFunc
- type Indexing
- type IndexingVisitor
- type IndexingVisitorFunc
- type IntLit
- type IntLitVisitor
- type IntLitVisitorFunc
- type ListLit
- type ListLitVisitor
- type ListLitVisitorFunc
- type Literal
- type Metadata
- type MetadataAttachment
- type MetadataKind
- type Module
- type ModuleSetter
- type Node
- type Operator
- type OperatorOverload
- type OperatorOverloadMap
- type ParameterInfo
- type ReturnStmt
- type ReturnStmtVisitor
- type ReturnStmtVisitorFunc
- type ScopeSetter
- type Statement
- type StringLit
- type StringLitVisitor
- type StringLitVisitorFunc
- type StructAlias
- type StructDecl
- func (decl *StructDecl) Accept(visitor FullVisitor) VisitResult
- func (decl *StructDecl) Comment() *token.Token
- func (decl *StructDecl) GetRange() token.Range
- func (decl *StructDecl) Module() *Module
- func (decl *StructDecl) Name() string
- func (decl *StructDecl) Public() bool
- func (decl *StructDecl) String() string
- func (decl *StructDecl) Token() token.Token
- type StructDeclVisitor
- type StructDeclVisitorFunc
- type StructLiteral
- type StructLiteralVisitor
- type StructLiteralVisitorFunc
- type SymbolTable
- type TernaryExpr
- type TernaryExprVisitor
- type TernaryExprVisitorFunc
- type TernaryOperator
- type TodoStmt
- type TodoStmtVisitor
- type TodoStmtVisitorFunc
- type TypeAliasDecl
- func (decl *TypeAliasDecl) Accept(visitor FullVisitor) VisitResult
- func (decl *TypeAliasDecl) Comment() *token.Token
- func (decl *TypeAliasDecl) GetRange() token.Range
- func (decl *TypeAliasDecl) Module() *Module
- func (decl *TypeAliasDecl) Name() string
- func (decl *TypeAliasDecl) Public() bool
- func (decl *TypeAliasDecl) String() string
- func (decl *TypeAliasDecl) Token() token.Token
- type TypeAliasDeclVisitor
- type TypeAliasDeclVisitorFunc
- type TypeCheck
- type TypeCheckVisitor
- type TypeCheckVisitorFunc
- type TypeDefDecl
- func (decl *TypeDefDecl) Accept(visitor FullVisitor) VisitResult
- func (decl *TypeDefDecl) Comment() *token.Token
- func (decl *TypeDefDecl) GetRange() token.Range
- func (decl *TypeDefDecl) Module() *Module
- func (decl *TypeDefDecl) Name() string
- func (decl *TypeDefDecl) Public() bool
- func (decl *TypeDefDecl) String() string
- func (decl *TypeDefDecl) Token() token.Token
- type TypeDefDeclVisitor
- type TypeDefDeclVisitorFunc
- type TypeOpExpr
- type TypeOpExprVisitor
- type TypeOpExprVisitorFunc
- type TypeOperator
- type UnaryExpr
- type UnaryExprVisitor
- type UnaryExprVisitorFunc
- type UnaryOperator
- type VarDecl
- func (decl *VarDecl) Accept(visitor FullVisitor) VisitResult
- func (decl *VarDecl) Comment() *token.Token
- func (decl *VarDecl) GetRange() token.Range
- func (decl *VarDecl) Module() *Module
- func (decl *VarDecl) Name() string
- func (decl *VarDecl) Public() bool
- func (decl *VarDecl) String() string
- func (decl *VarDecl) Token() token.Token
- type VarDeclVisitor
- type VarDeclVisitorFunc
- type VisitResult
- type Visitor
- type VisitorSetter
- type WhileStmt
- type WhileStmtVisitor
- type WhileStmtVisitorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsExternFunc ¶
check if the function is defined externally
func IsForwardDecl ¶
check if the declaration is only a forward decl
func IsGeneric ¶ added in v1.0.0
func IsGeneric(decl Declaration) bool
func IsGenericInstantiation ¶ added in v1.0.0
func IsGlobalScope ¶
func IsGlobalScope(table SymbolTable) bool
returns wether table is the global scope table.Enclosing == nil
func IsOperatorOverload ¶
func IsTypeDecl ¶ added in v1.0.0
func IsTypeDecl(decl Declaration) (ddptypes.Type, bool)
func IsVarConstDecl ¶ added in v1.0.0
func IsVarConstDecl(decl Declaration) bool
func IterateImportedDecls ¶
func IterateImportedDecls(imprt *ImportStmt, fun func(name string, decl Declaration, tok token.Token) bool)
applies fun to all declarations imported by imprt if len(imprt.ImportedSymbols) == 0, it is applied to all imprt.Module.PublicDecls, in which case the declarations are sorted by occurence in the source file otherwise to every tok in imprt.ImportedSymbols is used
- name is the name of the declaration (or the literal of imprt.ImportedSymbols if no decl is found)
- decl is nil if imprt.ImportedSymbols[x] is not present in import.Module.PublicDecls
- tok refers either to the string literal of the import path, or to the identifier from imprt.ImportedSymbols
the return value of fun indicates wether the iteration should continue or if we break true means continue, false means break
func IterateModuleImports ¶
Calls fun with module and every module it imports recursively meaning fun is called on module, all of its imports and all of their imports and so on a single time per module
func VisitModule ¶
visits the AST of the given module does nothing if module == nil
visitor can implement any of the Visit<Node> interfaces, and the corresponding method is called for each node
if the given Visitor implements the ConditionalVisitor interface, the ShouldVisit method is used to determine if a node should be visited
if the given Visitor implements the ScopeSetter interface, the SetScope method is called when the scope changes
if the given Visitor implements the ModuleSetter interface, the SetModule method is called before visiting the module
func VisitModuleRec ¶
visits the given module and all the modules it imports recursively does nothing if module == nil
visitor can implement any of the Visit<Node> interfaces, and the corresponding method is called for each node
imported modules are visited in the order they are included
if the given Visitor implements the ConditionalVisitor interface, the ShouldVisit method is used to determine if a node should be visited
if the given Visitor implements the ScopeSetter interface, the SetScope method is called when the scope changes
if the given Visitor implements the ModuleSetter interface, the SetModule method is called before visiting each module
func VisitNode ¶
func VisitNode(visitor Visitor, node Node, currentScope SymbolTable)
visits the given node and all its children recursively does nothing if node == nil
visitor can implement any of the Visit<Node> interfaces, and the corresponding method is called for each node
if the given Visitor implements the ConditionalVisitor interface, the ShouldVisit method is used to determine if a node should be visited
if the given Visitor implements the ScopeSetter interface, the SetScope method is called when the scope changes
Types ¶
type Alias ¶
type Alias interface {
// tokens of the alias
GetTokens() []token.Token
// tokens of the alias but as slice of *token.Token and without the EOF
// this is the slice that is used as keys in the AliasTrie
GetKey() []*token.Token
// the original string
GetOriginal() token.Token
// *FuncDecl or *StructDecl
Decl() Declaration
// types of the arguments (used for funcCall parsing)
GetArgs() map[string]ddptypes.ParameterType
}
interface for a alias of either a function or a struct constructor
type Annotator ¶
type Annotator Visitor
Annotator is a Visitor that can be used to annotate an AST with Metadata
type AssignStmt ¶
type AssignStmt struct {
Range token.Range
Tok token.Token
Var Assigneable // the variable to assign to
VarType ddptypes.Type // filled in by the typechecker, to keep information about typedefs
Rhs Expression // literal assign value
RhsType ddptypes.Type // filled in by the typechecker, to keep information about typedefs
}
func (*AssignStmt) Accept ¶
func (stmt *AssignStmt) Accept(v FullVisitor) VisitResult
func (*AssignStmt) GetRange ¶
func (stmt *AssignStmt) GetRange() token.Range
func (*AssignStmt) String ¶
func (stmt *AssignStmt) String() string
func (*AssignStmt) Token ¶
func (stmt *AssignStmt) Token() token.Token
type AssignStmtVisitor ¶
type AssignStmtVisitor interface {
Visitor
VisitAssignStmt(*AssignStmt) VisitResult
}
type AssignStmtVisitorFunc ¶
type AssignStmtVisitorFunc func(*AssignStmt) VisitResult
func (AssignStmtVisitorFunc) VisitAssignStmt ¶
func (f AssignStmtVisitorFunc) VisitAssignStmt(stmt *AssignStmt) VisitResult
func (AssignStmtVisitorFunc) Visitor ¶
func (AssignStmtVisitorFunc) Visitor()
type Assigneable ¶
type Assigneable interface {
Expression
// contains filtered or unexported methods
}
*Ident or *Indexing Nodes that fulfill this interface can be on the left side of an assignement (meaning, variables or references)
type Ast ¶
type Ast struct {
Statements []Statement // the top level statements
Comments []token.Token // all the comments in the source code
Symbols SymbolTable
Faulty bool // set if the ast has any errors (doesn't matter what from which phase they came)
// contains filtered or unexported fields
}
represents an Abstract Syntax Tree for a DDP program
func (*Ast) AddAttachement ¶
func (ast *Ast) AddAttachement(node Node, attachment MetadataAttachment)
adds metadata to the given node
func (*Ast) GetMetadata ¶
returns all the metadata attached to the given node
func (*Ast) GetMetadataByKind ¶
func (ast *Ast) GetMetadataByKind(node Node, kind MetadataKind) (MetadataAttachment, bool)
returns the metadata of the given kind attached to the given node
func (*Ast) RemoveAttachment ¶
func (ast *Ast) RemoveAttachment(node Node, kind MetadataKind)
removes metadata of the given kind from the given node
type BadDecl ¶
an invalid Declaration
func (*BadDecl) Accept ¶
func (decl *BadDecl) Accept(visitor FullVisitor) VisitResult
type BadDeclVisitor ¶
type BadDeclVisitor interface {
Visitor
VisitBadDecl(*BadDecl) VisitResult
}
type BadDeclVisitorFunc ¶
type BadDeclVisitorFunc func(*BadDecl) VisitResult
func (BadDeclVisitorFunc) VisitBadDecl ¶
func (f BadDeclVisitorFunc) VisitBadDecl(stmt *BadDecl) VisitResult
func (BadDeclVisitorFunc) Visitor ¶
func (BadDeclVisitorFunc) Visitor()
type BadExpr ¶
func (*BadExpr) Accept ¶
func (expr *BadExpr) Accept(v FullVisitor) VisitResult
type BadExprVisitor ¶
type BadExprVisitor interface {
Visitor
VisitBadExpr(*BadExpr) VisitResult
}
type BadExprVisitorFunc ¶
type BadExprVisitorFunc func(*BadExpr) VisitResult
Expressions
func (BadExprVisitorFunc) VisitBadExpr ¶
func (f BadExprVisitorFunc) VisitBadExpr(expr *BadExpr) VisitResult
func (BadExprVisitorFunc) Visitor ¶
func (BadExprVisitorFunc) Visitor()
type BadStmt ¶
func (*BadStmt) Accept ¶
func (stmt *BadStmt) Accept(v FullVisitor) VisitResult
type BadStmtVisitor ¶
type BadStmtVisitor interface {
Visitor
VisitBadStmt(*BadStmt) VisitResult
}
type BadStmtVisitorFunc ¶
type BadStmtVisitorFunc func(*BadStmt) VisitResult
Statements
func (BadStmtVisitorFunc) VisitBadStmt ¶
func (f BadStmtVisitorFunc) VisitBadStmt(stmt *BadStmt) VisitResult
func (BadStmtVisitorFunc) Visitor ¶
func (BadStmtVisitorFunc) Visitor()
type BaseVisitor ¶
type BaseVisitor struct {
// the current module being visited
CurrentModule *Module
// the current scope
CurrentScope SymbolTable
// Condition to check if a node should be visited
// if nil, all nodes are visited
VisitCondition func(Node) bool
}
A base visitor that can be embedded in other visitors to provide a default implementation for all methods and other utility functionality
func (*BaseVisitor) SetModule ¶
func (v *BaseVisitor) SetModule(m *Module)
func (*BaseVisitor) SetScope ¶
func (v *BaseVisitor) SetScope(s SymbolTable)
func (*BaseVisitor) ShouldVisit ¶
func (v *BaseVisitor) ShouldVisit(n Node) bool
func (*BaseVisitor) Visitor ¶
func (v *BaseVisitor) Visitor()
type BasicSymbolTable ¶ added in v1.0.0
type BasicSymbolTable struct {
EnclosingTable SymbolTable // enclosing scope (nil in the global scope)
Declarations map[string]Declaration // map of all variables, functions and structs
}
stores symbols for one scope of an ast
func (*BasicSymbolTable) Enclosing ¶ added in v1.0.0
func (scope *BasicSymbolTable) Enclosing() SymbolTable
func (*BasicSymbolTable) InsertDecl ¶ added in v1.0.0
func (scope *BasicSymbolTable) InsertDecl(name string, decl Declaration) bool
inserts a declaration into the scope if it didn't exist yet and returns wether it already existed BadDecls are ignored
func (*BasicSymbolTable) LookupDecl ¶ added in v1.0.0
func (scope *BasicSymbolTable) LookupDecl(name string) (Declaration, bool, bool)
returns the declaration corresponding to name and wether it exists if the symbol existed, the second bool is true, if it is a variable and false if it is a funciton call like this: decl, exists, isVar := LookupDecl(name)
func (*BasicSymbolTable) LookupType ¶ added in v1.0.0
func (scope *BasicSymbolTable) LookupType(name string) (ddptypes.Type, bool)
returns the given type if present, else nil
Type, ok := table.LookupType(name)
type BinaryExpr ¶
type BinaryExpr struct {
Range token.Range
Tok token.Token
Lhs Expression
Operator BinaryOperator
Rhs Expression
OverloadedBy *OperatorOverload
}
func (*BinaryExpr) Accept ¶
func (expr *BinaryExpr) Accept(v FullVisitor) VisitResult
func (*BinaryExpr) GetRange ¶
func (expr *BinaryExpr) GetRange() token.Range
func (*BinaryExpr) String ¶
func (expr *BinaryExpr) String() string
func (*BinaryExpr) Token ¶
func (expr *BinaryExpr) Token() token.Token
type BinaryExprVisitor ¶
type BinaryExprVisitor interface {
Visitor
VisitBinaryExpr(*BinaryExpr) VisitResult
}
type BinaryExprVisitorFunc ¶
type BinaryExprVisitorFunc func(*BinaryExpr) VisitResult
func (BinaryExprVisitorFunc) VisitBinaryExpr ¶
func (f BinaryExprVisitorFunc) VisitBinaryExpr(expr *BinaryExpr) VisitResult
func (BinaryExprVisitorFunc) Visitor ¶
func (BinaryExprVisitorFunc) Visitor()
type BinaryOperator ¶
type BinaryOperator int
const ( BIN_INVALID BinaryOperator = iota BIN_AND // und BIN_OR // oder BIN_XOR // entweder ... oder .. BIN_CONCAT // verkettet BIN_PLUS // plus BIN_MINUS // minus BIN_MULT // mal BIN_DIV // durch BIN_INDEX // an der Stelle BIN_POW // hoch BIN_LOG // Logarithmus BIN_LOGIC_AND // logisch und BIN_LOGIC_OR // logisch oder BIN_LOGIC_XOR // logisch kontra BIN_MOD // modulo BIN_LEFT_SHIFT // links verschoben BIN_RIGHT_SHIFT // rechts verschoben BIN_EQUAL // gleich BIN_UNEQUAL // ungleich BIN_LESS // kleiner BIN_GREATER // größer BIN_LESS_EQ // kleiner als, oder BIN_GREATER_EQ // größer als, oder BIN_FIELD_ACCESS // von BIN_SLICE_TO // bis zum BIN_SLICE_FROM // ab dem )
func (BinaryOperator) Operator ¶
func (BinaryOperator) Operator()
func (BinaryOperator) String ¶
func (op BinaryOperator) String() string
type BlockStmt ¶
type BlockStmt struct {
Range token.Range
Colon token.Token
Statements []Statement
Symbols SymbolTable
}
func (*BlockStmt) Accept ¶
func (stmt *BlockStmt) Accept(v FullVisitor) VisitResult
type BlockStmtVisitor ¶
type BlockStmtVisitor interface {
Visitor
VisitBlockStmt(*BlockStmt) VisitResult
}
type BlockStmtVisitorFunc ¶
type BlockStmtVisitorFunc func(*BlockStmt) VisitResult
func (BlockStmtVisitorFunc) VisitBlockStmt ¶
func (f BlockStmtVisitorFunc) VisitBlockStmt(stmt *BlockStmt) VisitResult
func (BlockStmtVisitorFunc) Visitor ¶
func (BlockStmtVisitorFunc) Visitor()
type BoolLit ¶
func (*BoolLit) Accept ¶
func (expr *BoolLit) Accept(v FullVisitor) VisitResult
type BoolLitVisitor ¶
type BoolLitVisitor interface {
Visitor
VisitBoolLit(*BoolLit) VisitResult
}
type BoolLitVisitorFunc ¶
type BoolLitVisitorFunc func(*BoolLit) VisitResult
func (BoolLitVisitorFunc) VisitBoolLit ¶
func (f BoolLitVisitorFunc) VisitBoolLit(expr *BoolLit) VisitResult
func (BoolLitVisitorFunc) Visitor ¶
func (BoolLitVisitorFunc) Visitor()
type BreakContinueStmt ¶
type BreakContinueStmt struct {
Range token.Range
Tok token.Token // VERLASSE for break, otherwise continue
}
func (*BreakContinueStmt) Accept ¶
func (stmt *BreakContinueStmt) Accept(v FullVisitor) VisitResult
func (*BreakContinueStmt) GetRange ¶
func (stmt *BreakContinueStmt) GetRange() token.Range
func (*BreakContinueStmt) String ¶
func (stmt *BreakContinueStmt) String() string
func (*BreakContinueStmt) Token ¶
func (stmt *BreakContinueStmt) Token() token.Token
type BreakContinueStmtVisitor ¶
type BreakContinueStmtVisitor interface {
Visitor
VisitBreakContinueStmt(*BreakContinueStmt) VisitResult
}
type BreakContinueStmtVisitorFunc ¶
type BreakContinueStmtVisitorFunc func(*BreakContinueStmt) VisitResult
func (BreakContinueStmtVisitorFunc) VisitBreakContinueStmt ¶
func (f BreakContinueStmtVisitorFunc) VisitBreakContinueStmt(stmt *BreakContinueStmt) VisitResult
func (BreakContinueStmtVisitorFunc) Visitor ¶
func (BreakContinueStmtVisitorFunc) Visitor()
type CastAssigneable ¶ added in v1.0.0
type CastAssigneable struct {
Range token.Range
TargetType ddptypes.Type
Lhs Assigneable
}
a CastExpr that can be assignable which is always a typedef/alias cast to its underlying type
func (*CastAssigneable) Accept ¶ added in v1.0.0
func (expr *CastAssigneable) Accept(v FullVisitor) VisitResult
func (*CastAssigneable) GetRange ¶ added in v1.0.0
func (expr *CastAssigneable) GetRange() token.Range
func (*CastAssigneable) String ¶ added in v1.0.0
func (expr *CastAssigneable) String() string
func (*CastAssigneable) Token ¶ added in v1.0.0
func (expr *CastAssigneable) Token() token.Token
type CastAssigneableVisitor ¶ added in v1.0.0
type CastAssigneableVisitor interface {
Visitor
VisitCastAssigneable(*CastAssigneable) VisitResult
}
type CastAssigneableVisitorFunc ¶ added in v1.0.0
type CastAssigneableVisitorFunc func(*CastAssigneable) VisitResult
func (CastAssigneableVisitorFunc) VisitCastAssigneable ¶ added in v1.0.0
func (f CastAssigneableVisitorFunc) VisitCastAssigneable(expr *CastAssigneable) VisitResult
func (CastAssigneableVisitorFunc) Visitor ¶ added in v1.0.0
func (CastAssigneableVisitorFunc) Visitor()
type CastExpr ¶
type CastExpr struct {
Range token.Range
TargetType ddptypes.Type
Lhs Expression
OverloadedBy *OperatorOverload
}
als Expressions cannot be unary because the type operator might be multiple tokens long
func (*CastExpr) Accept ¶
func (expr *CastExpr) Accept(v FullVisitor) VisitResult
type CastExprVisitor ¶
type CastExprVisitor interface {
Visitor
VisitCastExpr(*CastExpr) VisitResult
}
type CastExprVisitorFunc ¶
type CastExprVisitorFunc func(*CastExpr) VisitResult
func (CastExprVisitorFunc) VisitCastExpr ¶
func (f CastExprVisitorFunc) VisitCastExpr(expr *CastExpr) VisitResult
func (CastExprVisitorFunc) Visitor ¶
func (CastExprVisitorFunc) Visitor()
type CastOperator ¶
type CastOperator int
dummy type to support operator overloading on cast expressions
const ( CAST_INVALID CastOperator = iota CAST_OP // als )
func (CastOperator) Operator ¶
func (CastOperator) Operator()
func (CastOperator) String ¶
func (op CastOperator) String() string
type CharLit ¶
func (*CharLit) Accept ¶
func (expr *CharLit) Accept(v FullVisitor) VisitResult
type CharLitVisitor ¶
type CharLitVisitor interface {
Visitor
VisitCharLit(*CharLit) VisitResult
}
type CharLitVisitorFunc ¶
type CharLitVisitorFunc func(*CharLit) VisitResult
func (CharLitVisitorFunc) VisitCharLit ¶
func (f CharLitVisitorFunc) VisitCharLit(expr *CharLit) VisitResult
func (CharLitVisitorFunc) Visitor ¶
func (CharLitVisitorFunc) Visitor()
type ConditionalVisitor ¶
type ConditionalVisitor interface {
Visitor
// Condition to check if a node should be visited
ShouldVisit(Node) bool
}
when using the Visit* utility functions, this interface can be implemented to provide a condition to check if a node should be visited
type ConstDecl ¶
type ConstDecl struct {
Range token.Range
Mod *Module // the module in which the variable was declared
CommentTok *token.Token // optional comment (also contained in ast.Comments)
Type ddptypes.Type // type of the variable
NameTok token.Token // identifier name
Val Literal
IsPublic bool // wether the function is marked with öffentliche
}
func (*ConstDecl) Accept ¶
func (decl *ConstDecl) Accept(visitor FullVisitor) VisitResult
type ConstDeclVisitor ¶
type ConstDeclVisitor interface {
Visitor
VisitConstDecl(*ConstDecl) VisitResult
}
type ConstDeclVisitorFunc ¶
type ConstDeclVisitorFunc func(*ConstDecl) VisitResult
func (ConstDeclVisitorFunc) VisitConstDecl ¶
func (f ConstDeclVisitorFunc) VisitConstDecl(stmt *ConstDecl) VisitResult
func (ConstDeclVisitorFunc) Visitor ¶
func (ConstDeclVisitorFunc) Visitor()
type DeclStmt ¶
type DeclStmt struct {
Decl Declaration
}
func (*DeclStmt) Accept ¶
func (stmt *DeclStmt) Accept(v FullVisitor) VisitResult
type DeclStmtVisitor ¶
type DeclStmtVisitor interface {
Visitor
VisitDeclStmt(*DeclStmt) VisitResult
}
type DeclStmtVisitorFunc ¶
type DeclStmtVisitorFunc func(*DeclStmt) VisitResult
func (DeclStmtVisitorFunc) VisitDeclStmt ¶
func (f DeclStmtVisitorFunc) VisitDeclStmt(stmt *DeclStmt) VisitResult
func (DeclStmtVisitorFunc) Visitor ¶
func (DeclStmtVisitorFunc) Visitor()
type Declaration ¶
type Declaration interface {
Node
Name() string // returns the name of the declaration or "" for BadDecls
Public() bool // returns wether the declaration is public. always false for BadDecls
Comment() *token.Token // returns a optional comment
Module() *Module // returns the module from which the declaration comes
// contains filtered or unexported methods
}
basic Node interfaces
type ExprStmt ¶
type ExprStmt struct {
Expr Expression
}
func (*ExprStmt) Accept ¶
func (stmt *ExprStmt) Accept(v FullVisitor) VisitResult
type ExprStmtVisitor ¶
type ExprStmtVisitor interface {
Visitor
VisitExprStmt(*ExprStmt) VisitResult
}
type ExprStmtVisitorFunc ¶
type ExprStmtVisitorFunc func(*ExprStmt) VisitResult
func (ExprStmtVisitorFunc) VisitExprStmt ¶
func (f ExprStmtVisitorFunc) VisitExprStmt(stmt *ExprStmt) VisitResult
func (ExprStmtVisitorFunc) Visitor ¶
func (ExprStmtVisitorFunc) Visitor()
type Expression ¶
type Expression interface {
Node
// contains filtered or unexported methods
}
basic Node interfaces
type FieldAccess ¶
type FieldAccess struct {
Rhs Assigneable // variable Name or other indexing
Field *Ident // the field name
}
also exists as Binary expression for Literals this one can count as Reference, and my be used inplace of Ident (may be assigned to etc.)
func (*FieldAccess) Accept ¶
func (expr *FieldAccess) Accept(v FullVisitor) VisitResult
func (*FieldAccess) GetRange ¶
func (expr *FieldAccess) GetRange() token.Range
func (*FieldAccess) String ¶
func (expr *FieldAccess) String() string
func (*FieldAccess) Token ¶
func (expr *FieldAccess) Token() token.Token
type FieldAccessVisitor ¶
type FieldAccessVisitor interface {
Visitor
VisitFieldAccess(*FieldAccess) VisitResult
}
type FieldAccessVisitorFunc ¶
type FieldAccessVisitorFunc func(*FieldAccess) VisitResult
func (FieldAccessVisitorFunc) VisitFieldAccess ¶
func (f FieldAccessVisitorFunc) VisitFieldAccess(expr *FieldAccess) VisitResult
func (FieldAccessVisitorFunc) Visitor ¶
func (FieldAccessVisitorFunc) Visitor()
type FloatLit ¶
func (*FloatLit) Accept ¶
func (expr *FloatLit) Accept(v FullVisitor) VisitResult
type FloatLitVisitor ¶
type FloatLitVisitor interface {
Visitor
VisitFloatLit(*FloatLit) VisitResult
}
type FloatLitVisitorFunc ¶
type FloatLitVisitorFunc func(*FloatLit) VisitResult
func (FloatLitVisitorFunc) VisitFloatLit ¶
func (f FloatLitVisitorFunc) VisitFloatLit(expr *FloatLit) VisitResult
func (FloatLitVisitorFunc) Visitor ¶
func (FloatLitVisitorFunc) Visitor()
type ForRangeStmt ¶
type ForRangeStmt struct {
Range token.Range
For token.Token // Für
Initializer *VarDecl // InitVal is the same pointer as In
Index *VarDecl // optional index during iteration
In Expression // the string/list to range over
Body *BlockStmt
}
func (*ForRangeStmt) Accept ¶
func (stmt *ForRangeStmt) Accept(v FullVisitor) VisitResult
func (*ForRangeStmt) GetRange ¶
func (stmt *ForRangeStmt) GetRange() token.Range
func (*ForRangeStmt) String ¶
func (stmt *ForRangeStmt) String() string
func (*ForRangeStmt) Token ¶
func (stmt *ForRangeStmt) Token() token.Token
type ForRangeStmtVisitor ¶
type ForRangeStmtVisitor interface {
Visitor
VisitForRangeStmt(*ForRangeStmt) VisitResult
}
type ForRangeStmtVisitorFunc ¶
type ForRangeStmtVisitorFunc func(*ForRangeStmt) VisitResult
func (ForRangeStmtVisitorFunc) VisitForRangeStmt ¶
func (f ForRangeStmtVisitorFunc) VisitForRangeStmt(stmt *ForRangeStmt) VisitResult
func (ForRangeStmtVisitorFunc) Visitor ¶
func (ForRangeStmtVisitorFunc) Visitor()
type ForStmt ¶
type ForStmt struct {
Range token.Range
For token.Token // Für
Initializer *VarDecl // Zahl (name) von (Initializer.InitVal)
To Expression // bis (To)
StepSize Expression // Schrittgröße
Body *BlockStmt
}
func (*ForStmt) Accept ¶
func (stmt *ForStmt) Accept(v FullVisitor) VisitResult
type ForStmtVisitor ¶
type ForStmtVisitor interface {
Visitor
VisitForStmt(*ForStmt) VisitResult
}
type ForStmtVisitorFunc ¶
type ForStmtVisitorFunc func(*ForStmt) VisitResult
func (ForStmtVisitorFunc) VisitForStmt ¶
func (f ForStmtVisitorFunc) VisitForStmt(stmt *ForStmt) VisitResult
func (ForStmtVisitorFunc) Visitor ¶
func (ForStmtVisitorFunc) Visitor()
type FullVisitor ¶
type FullVisitor interface {
Visitor
BadDeclVisitor
ConstDeclVisitor
VarDeclVisitor
FuncDeclVisitor
FuncDefVisitor
StructDeclVisitor
TypeAliasDeclVisitor
TypeDefDeclVisitor
BadExprVisitor
IdentVisitor
IndexingVisitor
FieldAccessVisitor
IntLitVisitor
FloatLitVisitor
BoolLitVisitor
CharLitVisitor
StringLitVisitor
ListLitVisitor
UnaryExprVisitor
BinaryExprVisitor
TernaryExprVisitor
CastExprVisitor
CastAssigneableVisitor
TypeOpExprVisitor
TypeCheckVisitor
GroupingVisitor
FuncCallVisitor
StructLiteralVisitor
BadStmtVisitor
DeclStmtVisitor
ExprStmtVisitor
ImportStmtVisitor
AssignStmtVisitor
BlockStmtVisitor
IfStmtVisitor
WhileStmtVisitor
ForStmtVisitor
ForRangeStmtVisitor
BreakContinueStmtVisitor
ReturnStmtVisitor
TodoStmtVisitor
}
interface for visiting DDP expressions, statements and declarations see the Visitor pattern
type FuncAlias ¶
type FuncAlias struct {
Tokens []token.Token // tokens of the alias
Original token.Token // the original string
Func *FuncDecl // the function it refers to (if it is used outside a FuncDecl)
Args map[string]ddptypes.ParameterType // types of the arguments (used for funcCall parsing)
Negated bool // if the alias has been negated
// contains filtered or unexported fields
}
wrapper for a function alias
func (*FuncAlias) Decl ¶
func (alias *FuncAlias) Decl() Declaration
func (*FuncAlias) GetOriginal ¶
type FuncCall ¶
type FuncCall struct {
Range token.Range
Tok token.Token // first token of the call
Name string // name of the function
// the function declaration this call refers to
// is set by the parser, or nil if the name was not found
Func *FuncDecl
Args map[string]Expression
}
func (*FuncCall) Accept ¶
func (expr *FuncCall) Accept(v FullVisitor) VisitResult
type FuncCallVisitor ¶
type FuncCallVisitor interface {
Visitor
VisitFuncCall(*FuncCall) VisitResult
}
type FuncCallVisitorFunc ¶
type FuncCallVisitorFunc func(*FuncCall) VisitResult
func (FuncCallVisitorFunc) VisitFuncCall ¶
func (f FuncCallVisitorFunc) VisitFuncCall(expr *FuncCall) VisitResult
func (FuncCallVisitorFunc) Visitor ¶
func (FuncCallVisitorFunc) Visitor()
type FuncDecl ¶
type FuncDecl struct {
Range token.Range
CommentTok *token.Token // optional comment (also contained in ast.Comments)
Tok token.Token // Die
NameTok token.Token // token of the name
IsPublic bool // wether the function is marked with öffentliche
IsExternVisible bool // wether the function is marked as extern visible
Mod *Module // the module in which the function was declared
Parameters []ParameterInfo // name, type and comments of parameters
ReturnType ddptypes.Type // return Type, Zahl Kommazahl nichts ...
ReturnTypeRange token.Range // range of the return type (mainly used by the LSP)
Body *BlockStmt // nil for extern functions or forward declarations
Def *FuncDef // non-nil for forward declarations
ExternFile token.Token // string literal with filepath (only pesent if Body is nil)
Operator Operator // the operator this function overloads, or nil if it does not overload an operator
Generic *GenericFuncInfo // only filled if the function was declared as generic
GenericInstantiation *GenericInstantiationInfo // non-nil if this decl is a instantiation of a generic function
Aliases []*FuncAlias
}
func (*FuncDecl) Accept ¶
func (decl *FuncDecl) Accept(visitor FullVisitor) VisitResult
type FuncDeclVisitor ¶
type FuncDeclVisitor interface {
Visitor
VisitFuncDecl(*FuncDecl) VisitResult
}
type FuncDeclVisitorFunc ¶
type FuncDeclVisitorFunc func(*FuncDecl) VisitResult
func (FuncDeclVisitorFunc) VisitFuncDecl ¶
func (f FuncDeclVisitorFunc) VisitFuncDecl(stmt *FuncDecl) VisitResult
func (FuncDeclVisitorFunc) Visitor ¶
func (FuncDeclVisitorFunc) Visitor()
type FuncDef ¶
is a statement and not a declaration but grouped in this File with FuncDecl for readability
func (*FuncDef) Accept ¶
func (decl *FuncDef) Accept(visitor FullVisitor) VisitResult
type FuncDefVisitor ¶
type FuncDefVisitor interface {
Visitor
VisitFuncDef(*FuncDef) VisitResult
}
type FuncDefVisitorFunc ¶
type FuncDefVisitorFunc func(*FuncDef) VisitResult
func (FuncDefVisitorFunc) VisitFuncDef ¶
func (f FuncDefVisitorFunc) VisitFuncDef(stmt *FuncDef) VisitResult
func (FuncDefVisitorFunc) Visitor ¶
func (FuncDefVisitorFunc) Visitor()
type GenericContext ¶ added in v1.0.0
type GenericContext struct {
Symbols SymbolTable
Aliases AliasTrie
Operators map[Operator][]*FuncDecl
}
the context captured by a generic function declaration to parse an instantiation it has to be merged with the symbols and aliases at the point of instantiation
type GenericFuncInfo ¶ added in v1.0.0
type GenericFuncInfo struct {
Types map[string]ddptypes.GenericType // all declared generic types
Tokens []token.Token // tokens of the body that need to be parsed, nil if the function is extern
Context GenericContext // context up to the point where the function was declared
Instantiations map[*Module][]*FuncDecl // all existing instantiations for a given module
}
holds information about a generic function declaration
type GenericInstantiationInfo ¶ added in v1.0.0
type Grouping ¶
type Grouping struct {
Range token.Range
LParen token.Token // (
Expr Expression
}
func (*Grouping) Accept ¶
func (expr *Grouping) Accept(v FullVisitor) VisitResult
type GroupingVisitor ¶
type GroupingVisitor interface {
Visitor
VisitGrouping(*Grouping) VisitResult
}
type GroupingVisitorFunc ¶
type GroupingVisitorFunc func(*Grouping) VisitResult
func (GroupingVisitorFunc) VisitGrouping ¶
func (f GroupingVisitorFunc) VisitGrouping(expr *Grouping) VisitResult
func (GroupingVisitorFunc) Visitor ¶
func (GroupingVisitorFunc) Visitor()
type Ident ¶
type Ident struct {
Literal token.Token
// the variable declaration this identifier refers to
// is set by the resolver, or nil if the name was not found
Declaration Declaration
}
func (*Ident) Accept ¶
func (expr *Ident) Accept(v FullVisitor) VisitResult
type IdentVisitor ¶
type IdentVisitor interface {
Visitor
VisitIdent(*Ident) VisitResult
}
type IdentVisitorFunc ¶
type IdentVisitorFunc func(*Ident) VisitResult
func (IdentVisitorFunc) VisitIdent ¶
func (f IdentVisitorFunc) VisitIdent(expr *Ident) VisitResult
func (IdentVisitorFunc) Visitor ¶
func (IdentVisitorFunc) Visitor()
type IfStmt ¶
type IfStmt struct {
Range token.Range
If token.Token // wenn/aber
Condition Expression
Then Statement
Else Statement
}
func (*IfStmt) Accept ¶
func (stmt *IfStmt) Accept(v FullVisitor) VisitResult
type IfStmtVisitor ¶
type IfStmtVisitor interface {
Visitor
VisitIfStmt(*IfStmt) VisitResult
}
type IfStmtVisitorFunc ¶
type IfStmtVisitorFunc func(*IfStmt) VisitResult
func (IfStmtVisitorFunc) VisitIfStmt ¶
func (f IfStmtVisitorFunc) VisitIfStmt(stmt *IfStmt) VisitResult
func (IfStmtVisitorFunc) Visitor ¶
func (IfStmtVisitorFunc) Visitor()
type ImportStmt ¶
type ImportStmt struct {
Range token.Range
// wether the statement imported a directory
IsDirectoryImport bool
// wether the statement was a recursive import
// only true if IsDirectoryImport is also true
IsRecursive bool
// the string literal which specified the filename
FileName token.Token
// all modules that were imported because of this statement
// nil if it does not exist or a similar error occured while importing
Modules []*Module
// slice of identifiers which specify
// the individual symbols imported
// if nil, all symbols are imported
ImportedSymbols []token.Token
}
import statement for meta-information in the ast will be already resolved by the parser
func (*ImportStmt) Accept ¶
func (stmt *ImportStmt) Accept(v FullVisitor) VisitResult
func (*ImportStmt) GetRange ¶
func (stmt *ImportStmt) GetRange() token.Range
func (*ImportStmt) SingleModule ¶
func (stmt *ImportStmt) SingleModule() *Module
If this statement was not a directory import, returns the one imported module
func (*ImportStmt) String ¶
func (stmt *ImportStmt) String() string
func (*ImportStmt) Token ¶
func (stmt *ImportStmt) Token() token.Token
type ImportStmtVisitor ¶
type ImportStmtVisitor interface {
Visitor
VisitImportStmt(*ImportStmt) VisitResult
}
type ImportStmtVisitorFunc ¶
type ImportStmtVisitorFunc func(*ImportStmt) VisitResult
func (ImportStmtVisitorFunc) VisitImportStmt ¶
func (f ImportStmtVisitorFunc) VisitImportStmt(stmt *ImportStmt) VisitResult
func (ImportStmtVisitorFunc) Visitor ¶
func (ImportStmtVisitorFunc) Visitor()
type Indexing ¶
type Indexing struct {
Lhs Assigneable // variable Name or other indexing
Index Expression
}
also exists as Binary expression for Literals this one can count as Reference, and may be used inplace of Ident (may be assigned to etc.)
func (*Indexing) Accept ¶
func (expr *Indexing) Accept(v FullVisitor) VisitResult
type IndexingVisitor ¶
type IndexingVisitor interface {
Visitor
VisitIndexing(*Indexing) VisitResult
}
type IndexingVisitorFunc ¶
type IndexingVisitorFunc func(*Indexing) VisitResult
func (IndexingVisitorFunc) VisitIndexing ¶
func (f IndexingVisitorFunc) VisitIndexing(expr *Indexing) VisitResult
func (IndexingVisitorFunc) Visitor ¶
func (IndexingVisitorFunc) Visitor()
type IntLit ¶
func (*IntLit) Accept ¶
func (expr *IntLit) Accept(v FullVisitor) VisitResult
type IntLitVisitor ¶
type IntLitVisitor interface {
Visitor
VisitIntLit(*IntLit) VisitResult
}
type IntLitVisitorFunc ¶
type IntLitVisitorFunc func(*IntLit) VisitResult
func (IntLitVisitorFunc) VisitIntLit ¶
func (f IntLitVisitorFunc) VisitIntLit(expr *IntLit) VisitResult
func (IntLitVisitorFunc) Visitor ¶
func (IntLitVisitorFunc) Visitor()
type ListLit ¶
type ListLit struct {
Tok token.Token
Range token.Range
// type of the empty list if Values is nil
// the typechecker fills this field if Values is non-nil
Type ddptypes.ListType
Values []Expression // the values in the Literal
// if Values, Count and Value are nil, the list is empty
Count Expression // for big list initializations
Value Expression // the default value for big list initializations
}
func (*ListLit) Accept ¶
func (expr *ListLit) Accept(v FullVisitor) VisitResult
type ListLitVisitor ¶
type ListLitVisitor interface {
Visitor
VisitListLit(*ListLit) VisitResult
}
type ListLitVisitorFunc ¶
type ListLitVisitorFunc func(*ListLit) VisitResult
func (ListLitVisitorFunc) VisitListLit ¶
func (f ListLitVisitorFunc) VisitListLit(expr *ListLit) VisitResult
func (ListLitVisitorFunc) Visitor ¶
func (ListLitVisitorFunc) Visitor()
type Literal ¶
type Literal interface {
Expression
// contains filtered or unexported methods
}
type Metadata ¶
type Metadata struct {
// Attachements stored by kind
Attachments map[MetadataKind]MetadataAttachment
}
a collection of MetadataAttachments for a node
type MetadataAttachment ¶
type MetadataAttachment interface {
String() string
// kind of the attachement (e.g. "range", "constant_info", "type_info", etc. or any custom string)
// should be a unique string for each kind of metadata as it is the key in the
// attachments map
Kind() MetadataKind
}
type MetadataKind ¶
type MetadataKind string
type Module ¶
type Module struct {
// the absolute filepath from which the module comes
FileName string
// the token which specified the relative FileName
// if the module was imported and not the main Module
FileNameToken *token.Token
// all the imported modules
Imports []*ImportStmt
// First token in the file if present, or nil otherwise
Comment *token.Token
// a set which contains all files needed
// to link the final executable
// contains .c, .lib, .a and .o files
ExternalDependencies map[string]struct{}
// the Ast of the Module
Ast *Ast
// map of references to all public functions, variables and structs
PublicDecls map[string]Declaration
// map of all overloads for all operators
Operators OperatorOverloadMap
}
represents a single DDP Module (source file), it's dependencies and public interface
func (*Module) GetIncludeFilename ¶
returns the string-literal content by which this module was first imported or the short FileName if it is the main module
type ModuleSetter ¶
when using the Visit* utility functions, this interface can be implemented to retreive the current module
type Node ¶
type Node interface {
fmt.Stringer
Token() token.Token
GetRange() token.Range
Accept(FullVisitor) VisitResult
// contains filtered or unexported methods
}
basic Node interfaces
type Operator ¶
type Operator interface {
String() string
Operator() // dummy function for the interface
}
interface for operator enums to use them easier in generic functions
func GetOperator ¶
returns the corresponding Operator for it's string representation
type OperatorOverload ¶
type OperatorOverload struct {
Decl *FuncDecl // the function that overloads the operator
Args map[string]Expression // the parsed (assigneable) arguments for the operator
}
holds information on the parsed operator-overload for an expression
type OperatorOverloadMap ¶ added in v1.0.0
type ParameterInfo ¶
type ParameterInfo struct {
Name token.Token // the name token of the parameter
Type ddptypes.ParameterType // the type of the parameter or default value if there was an error during parsing
TypeRange token.Range // range of the type (mainly for the LSP)
Comment *token.Token // the comment token, or nil if none was present
}
holds all information about a single function parameter
func (*ParameterInfo) HasValidType ¶
func (param *ParameterInfo) HasValidType() bool
wether the ParameterInfo's type is not the default value (i.e. was not parsed)
type ReturnStmt ¶
type ReturnStmt struct {
Range token.Range
Return token.Token // Gib
Func *FuncDecl
Value Expression // nil for void return
}
func (*ReturnStmt) Accept ¶
func (stmt *ReturnStmt) Accept(v FullVisitor) VisitResult
func (*ReturnStmt) GetRange ¶
func (stmt *ReturnStmt) GetRange() token.Range
func (*ReturnStmt) String ¶
func (stmt *ReturnStmt) String() string
func (*ReturnStmt) Token ¶
func (stmt *ReturnStmt) Token() token.Token
type ReturnStmtVisitor ¶
type ReturnStmtVisitor interface {
Visitor
VisitReturnStmt(*ReturnStmt) VisitResult
}
type ReturnStmtVisitorFunc ¶
type ReturnStmtVisitorFunc func(*ReturnStmt) VisitResult
func (ReturnStmtVisitorFunc) VisitReturnStmt ¶
func (f ReturnStmtVisitorFunc) VisitReturnStmt(stmt *ReturnStmt) VisitResult
func (ReturnStmtVisitorFunc) Visitor ¶
func (ReturnStmtVisitorFunc) Visitor()
type ScopeSetter ¶
type ScopeSetter interface {
Visitor
// called before entering a scope in the AST
SetScope(SymbolTable)
}
when using the Visit* utility functions, this interface can be implemented to set the current scope
type Statement ¶
type Statement interface {
Node
// contains filtered or unexported methods
}
basic Node interfaces
type StringLit ¶
func (*StringLit) Accept ¶
func (expr *StringLit) Accept(v FullVisitor) VisitResult
type StringLitVisitor ¶
type StringLitVisitor interface {
Visitor
VisitStringLit(*StringLit) VisitResult
}
type StringLitVisitorFunc ¶
type StringLitVisitorFunc func(*StringLit) VisitResult
func (StringLitVisitorFunc) VisitStringLit ¶
func (f StringLitVisitorFunc) VisitStringLit(expr *StringLit) VisitResult
func (StringLitVisitorFunc) Visitor ¶
func (StringLitVisitorFunc) Visitor()
type StructAlias ¶
type StructAlias struct {
Tokens []token.Token // tokens of the alias
Original token.Token // the original string
Struct *StructDecl // the struct decl it refers to
Args map[string]ddptypes.Type // types of the arguments (only those that the alias needs)
// contains filtered or unexported fields
}
wrapper for a struct alias
func (*StructAlias) Decl ¶
func (alias *StructAlias) Decl() Declaration
func (*StructAlias) GetArgs ¶
func (alias *StructAlias) GetArgs() map[string]ddptypes.ParameterType
func (*StructAlias) GetKey ¶ added in v1.0.0
func (alias *StructAlias) GetKey() []*token.Token
func (*StructAlias) GetOriginal ¶
func (alias *StructAlias) GetOriginal() token.Token
func (*StructAlias) GetTokens ¶
func (alias *StructAlias) GetTokens() []token.Token
type StructDecl ¶
type StructDecl struct {
Range token.Range
CommentTok *token.Token // optional comment (also contained in ast.Comments)
Tok token.Token // Wir
NameTok token.Token // token of the name
IsPublic bool // wether the struct decl is marked with öffentliche
Mod *Module // the module in which the struct was declared
// Field declarations of the struct in order of declaration
// only contains *VarDecl and *BadDecl s
Fields []Declaration
Type ddptypes.Type // the type resulting from this decl
Aliases []*StructAlias // the constructors of the struct
}
func (*StructDecl) Accept ¶
func (decl *StructDecl) Accept(visitor FullVisitor) VisitResult
func (*StructDecl) Comment ¶
func (decl *StructDecl) Comment() *token.Token
func (*StructDecl) GetRange ¶
func (decl *StructDecl) GetRange() token.Range
func (*StructDecl) Module ¶
func (decl *StructDecl) Module() *Module
func (*StructDecl) Name ¶
func (decl *StructDecl) Name() string
func (*StructDecl) Public ¶
func (decl *StructDecl) Public() bool
func (*StructDecl) String ¶
func (decl *StructDecl) String() string
func (*StructDecl) Token ¶
func (decl *StructDecl) Token() token.Token
type StructDeclVisitor ¶
type StructDeclVisitor interface {
Visitor
VisitStructDecl(*StructDecl) VisitResult
}
type StructDeclVisitorFunc ¶
type StructDeclVisitorFunc func(*StructDecl) VisitResult
func (StructDeclVisitorFunc) VisitStructDecl ¶
func (f StructDeclVisitorFunc) VisitStructDecl(stmt *StructDecl) VisitResult
func (StructDeclVisitorFunc) Visitor ¶
func (StructDeclVisitorFunc) Visitor()
type StructLiteral ¶
type StructLiteral struct {
Range token.Range
Tok token.Token // first token of the literal
// the struct declaration this literal refers to
// is set by the parser, or nil if the name was not found
Struct *StructDecl
// the actual struct type which may be instantiated from a generic
// and therefore different than Struct.Type
Type *ddptypes.StructType
// the arguments passed to the literal
// this does not include all struct fields,
// only the ones needed by the alias used
Args map[string]Expression
}
func (*StructLiteral) Accept ¶
func (expr *StructLiteral) Accept(v FullVisitor) VisitResult
func (*StructLiteral) GetRange ¶
func (expr *StructLiteral) GetRange() token.Range
func (*StructLiteral) String ¶
func (expr *StructLiteral) String() string
func (*StructLiteral) Token ¶
func (expr *StructLiteral) Token() token.Token
type StructLiteralVisitor ¶
type StructLiteralVisitor interface {
Visitor
VisitStructLiteral(*StructLiteral) VisitResult
}
type StructLiteralVisitorFunc ¶
type StructLiteralVisitorFunc func(*StructLiteral) VisitResult
func (StructLiteralVisitorFunc) VisitStructLiteral ¶
func (f StructLiteralVisitorFunc) VisitStructLiteral(expr *StructLiteral) VisitResult
func (StructLiteralVisitorFunc) Visitor ¶
func (StructLiteralVisitorFunc) Visitor()
type SymbolTable ¶
type SymbolTable interface {
// returns the enclosing scope (nil in the global scope)
Enclosing() SymbolTable
// returns the declaration corresponding to name and wether it exists
// if the symbol existed, the second bool is true, if it is a variable and false if it is a funciton
// call like this: decl, exists, isVar := LookupDecl(name)
LookupDecl(name string) (Declaration, bool, bool)
// inserts a declaration into the scope if it didn't exist yet
// and returns wether it already existed
// BadDecls are ignored
InsertDecl(name string, decl Declaration) bool
// returns the given type if present, else nil
//
// Type, ok := table.LookupType(name)
LookupType(name string) (ddptypes.Type, bool)
}
func NewSymbolTable ¶
func NewSymbolTable(enclosing SymbolTable) SymbolTable
type TernaryExpr ¶
type TernaryExpr struct {
Range token.Range
Tok token.Token
Lhs Expression
Mid Expression
Rhs Expression
Operator TernaryOperator
OverloadedBy *OperatorOverload
}
currently only used for von bis
func (*TernaryExpr) Accept ¶
func (expr *TernaryExpr) Accept(v FullVisitor) VisitResult
func (*TernaryExpr) GetRange ¶
func (expr *TernaryExpr) GetRange() token.Range
func (*TernaryExpr) String ¶
func (expr *TernaryExpr) String() string
func (*TernaryExpr) Token ¶
func (expr *TernaryExpr) Token() token.Token
type TernaryExprVisitor ¶
type TernaryExprVisitor interface {
Visitor
VisitTernaryExpr(*TernaryExpr) VisitResult
}
type TernaryExprVisitorFunc ¶
type TernaryExprVisitorFunc func(*TernaryExpr) VisitResult
func (TernaryExprVisitorFunc) VisitTernaryExpr ¶
func (f TernaryExprVisitorFunc) VisitTernaryExpr(expr *TernaryExpr) VisitResult
func (TernaryExprVisitorFunc) Visitor ¶
func (TernaryExprVisitorFunc) Visitor()
type TernaryOperator ¶
type TernaryOperator int
const ( TER_INVALID TernaryOperator = iota TER_SLICE // von bis TER_BETWEEN // zwischen TER_FALLS // <a>, falls <b>, ansonsten <c> )
func (TernaryOperator) Operator ¶
func (TernaryOperator) Operator()
func (TernaryOperator) String ¶
func (op TernaryOperator) String() string
type TodoStmt ¶
func (*TodoStmt) Accept ¶
func (stmt *TodoStmt) Accept(v FullVisitor) VisitResult
type TodoStmtVisitor ¶
type TodoStmtVisitor interface {
Visitor
VisitTodoStmt(*TodoStmt) VisitResult
}
type TodoStmtVisitorFunc ¶
type TodoStmtVisitorFunc func(*TodoStmt) VisitResult
func (TodoStmtVisitorFunc) VisitTodoStmt ¶
func (f TodoStmtVisitorFunc) VisitTodoStmt(stmt *TodoStmt) VisitResult
func (TodoStmtVisitorFunc) Visitor ¶
func (TodoStmtVisitorFunc) Visitor()
type TypeAliasDecl ¶
type TypeAliasDecl struct {
Range token.Range
CommentTok *token.Token // optional comment
Tok token.Token // Wir
NameTok token.Token // token of the name
IsPublic bool
Mod *Module
Underlying ddptypes.Type // the underlying type
UnderlyingRange token.Range // range of the underlying type (mainly used by the LSP)
Type *ddptypes.TypeAlias // the resulting TypeAlias type
}
func (*TypeAliasDecl) Accept ¶
func (decl *TypeAliasDecl) Accept(visitor FullVisitor) VisitResult
func (*TypeAliasDecl) Comment ¶
func (decl *TypeAliasDecl) Comment() *token.Token
func (*TypeAliasDecl) GetRange ¶
func (decl *TypeAliasDecl) GetRange() token.Range
func (*TypeAliasDecl) Module ¶
func (decl *TypeAliasDecl) Module() *Module
func (*TypeAliasDecl) Name ¶
func (decl *TypeAliasDecl) Name() string
func (*TypeAliasDecl) Public ¶
func (decl *TypeAliasDecl) Public() bool
func (*TypeAliasDecl) String ¶
func (decl *TypeAliasDecl) String() string
func (*TypeAliasDecl) Token ¶
func (decl *TypeAliasDecl) Token() token.Token
type TypeAliasDeclVisitor ¶
type TypeAliasDeclVisitor interface {
Visitor
VisitTypeAliasDecl(*TypeAliasDecl) VisitResult
}
type TypeAliasDeclVisitorFunc ¶
type TypeAliasDeclVisitorFunc func(*TypeAliasDecl) VisitResult
func (TypeAliasDeclVisitorFunc) VisitTypeAliasDecl ¶
func (f TypeAliasDeclVisitorFunc) VisitTypeAliasDecl(stmt *TypeAliasDecl) VisitResult
func (TypeAliasDeclVisitorFunc) Visitor ¶
func (TypeAliasDeclVisitorFunc) Visitor()
type TypeCheck ¶
ein/eine, seperate from CastExpr as it should not be overloadable
func (*TypeCheck) Accept ¶
func (expr *TypeCheck) Accept(v FullVisitor) VisitResult
type TypeCheckVisitor ¶
type TypeCheckVisitor interface {
Visitor
VisitTypeCheck(*TypeCheck) VisitResult
}
type TypeCheckVisitorFunc ¶
type TypeCheckVisitorFunc func(*TypeCheck) VisitResult
func (TypeCheckVisitorFunc) VisitTypeCheck ¶
func (f TypeCheckVisitorFunc) VisitTypeCheck(expr *TypeCheck) VisitResult
func (TypeCheckVisitorFunc) Visitor ¶
func (TypeCheckVisitorFunc) Visitor()
type TypeDefDecl ¶
type TypeDefDecl struct {
Range token.Range
CommentTok *token.Token // optional comment
Tok token.Token // Wir
NameTok token.Token // token of the name
IsPublic bool
Mod *Module
Underlying ddptypes.Type // the underlying type
UnderlyingRange token.Range // range of the underlying type (mainly used by the LSP)
Type *ddptypes.TypeDef // the resulting TypeDef type
}
func (*TypeDefDecl) Accept ¶
func (decl *TypeDefDecl) Accept(visitor FullVisitor) VisitResult
func (*TypeDefDecl) Comment ¶
func (decl *TypeDefDecl) Comment() *token.Token
func (*TypeDefDecl) GetRange ¶
func (decl *TypeDefDecl) GetRange() token.Range
func (*TypeDefDecl) Module ¶
func (decl *TypeDefDecl) Module() *Module
func (*TypeDefDecl) Name ¶
func (decl *TypeDefDecl) Name() string
func (*TypeDefDecl) Public ¶
func (decl *TypeDefDecl) Public() bool
func (*TypeDefDecl) String ¶
func (decl *TypeDefDecl) String() string
func (*TypeDefDecl) Token ¶
func (decl *TypeDefDecl) Token() token.Token
type TypeDefDeclVisitor ¶
type TypeDefDeclVisitor interface {
Visitor
VisitTypeDefDecl(*TypeDefDecl) VisitResult
}
type TypeDefDeclVisitorFunc ¶
type TypeDefDeclVisitorFunc func(*TypeDefDecl) VisitResult
func (TypeDefDeclVisitorFunc) VisitTypeDefDecl ¶
func (f TypeDefDeclVisitorFunc) VisitTypeDefDecl(stmt *TypeDefDecl) VisitResult
func (TypeDefDeclVisitorFunc) Visitor ¶
func (TypeDefDeclVisitorFunc) Visitor()
type TypeOpExpr ¶
type TypeOpExpr struct {
Range token.Range
Tok token.Token
Operator TypeOperator
Rhs ddptypes.Type
}
expressions that operate on types (Standardwert, Größe, ein/eine)
func (*TypeOpExpr) Accept ¶
func (expr *TypeOpExpr) Accept(v FullVisitor) VisitResult
func (*TypeOpExpr) GetRange ¶
func (expr *TypeOpExpr) GetRange() token.Range
func (*TypeOpExpr) String ¶
func (expr *TypeOpExpr) String() string
func (*TypeOpExpr) Token ¶
func (expr *TypeOpExpr) Token() token.Token
type TypeOpExprVisitor ¶
type TypeOpExprVisitor interface {
Visitor
VisitTypeOpExpr(*TypeOpExpr) VisitResult
}
type TypeOpExprVisitorFunc ¶
type TypeOpExprVisitorFunc func(*TypeOpExpr) VisitResult
func (TypeOpExprVisitorFunc) VisitTypeOpExpr ¶
func (f TypeOpExprVisitorFunc) VisitTypeOpExpr(expr *TypeOpExpr) VisitResult
func (TypeOpExprVisitorFunc) Visitor ¶
func (TypeOpExprVisitorFunc) Visitor()
type TypeOperator ¶
type TypeOperator int
const ( TYPE_INVALID TypeOperator = iota TYPE_SIZE // Größe TYPE_DEFAULT // Standardwert TYPE_OF // ein, eine )
func (TypeOperator) Operator ¶
func (TypeOperator) Operator()
func (TypeOperator) String ¶
func (op TypeOperator) String() string
type UnaryExpr ¶
type UnaryExpr struct {
Range token.Range
Tok token.Token
Operator UnaryOperator
Rhs Expression
OverloadedBy *OperatorOverload
}
func (*UnaryExpr) Accept ¶
func (expr *UnaryExpr) Accept(v FullVisitor) VisitResult
type UnaryExprVisitor ¶
type UnaryExprVisitor interface {
Visitor
VisitUnaryExpr(*UnaryExpr) VisitResult
}
type UnaryExprVisitorFunc ¶
type UnaryExprVisitorFunc func(*UnaryExpr) VisitResult
func (UnaryExprVisitorFunc) VisitUnaryExpr ¶
func (f UnaryExprVisitorFunc) VisitUnaryExpr(expr *UnaryExpr) VisitResult
func (UnaryExprVisitorFunc) Visitor ¶
func (UnaryExprVisitorFunc) Visitor()
type UnaryOperator ¶
type UnaryOperator int
const ( UN_INVALID UnaryOperator = iota UN_ABS // Betrag von UN_LEN // Länge von UN_NEGATE // - UN_NOT // nicht UN_LOGIC_NOT // logisch nicht )
func (UnaryOperator) Operator ¶
func (UnaryOperator) Operator()
func (UnaryOperator) String ¶
func (op UnaryOperator) String() string
type VarDecl ¶
type VarDecl struct {
Range token.Range
CommentTok *token.Token // optional comment (also contained in ast.Comments)
Type ddptypes.Type // type of the variable
NameTok token.Token // identifier name
TypeRange token.Range // range of the type (mainly used by the LSP)
IsPublic bool // whether the function is marked with öffentliche
IsExternVisible bool // whether the variable is marked as extern visible
IsGlobal bool // whether this is a global variable
Mod *Module // the module in which the variable was declared
InitVal Expression // initial value
InitType ddptypes.Type // type of InitVal, filled in by the typechecker, used to keep information about typedefs
}
func (*VarDecl) Accept ¶
func (decl *VarDecl) Accept(visitor FullVisitor) VisitResult
type VarDeclVisitor ¶
type VarDeclVisitor interface {
Visitor
VisitVarDecl(*VarDecl) VisitResult
}
type VarDeclVisitorFunc ¶
type VarDeclVisitorFunc func(*VarDecl) VisitResult
func (VarDeclVisitorFunc) VisitVarDecl ¶
func (f VarDeclVisitorFunc) VisitVarDecl(stmt *VarDecl) VisitResult
func (VarDeclVisitorFunc) Visitor ¶
func (VarDeclVisitorFunc) Visitor()
type VisitResult ¶
type VisitResult uint8
result type of all Visitor methods
const ( VisitRecurse VisitResult = iota // visiting continues normally VisitSkipChildren // children of the node are not visited VisitBreak // visiting is stopped )
type Visitor ¶
type Visitor interface {
Visitor() // dummy function for the interface
}
base interface for all visitors this interface itself is useless, implement one of the sub-interfaces for the actual functionality
type VisitorSetter ¶ added in v1.0.0
type VisitorSetter interface {
Visitor
SetVisitor(FullVisitor)
}
when using Visit* utility functions, this interface can be implemented to retreive the actual visitor
type WhileStmt ¶
type WhileStmt struct {
Range token.Range
While token.Token // solange, mache, mal
Condition Expression
Body Statement
}
func (*WhileStmt) Accept ¶
func (stmt *WhileStmt) Accept(v FullVisitor) VisitResult
type WhileStmtVisitor ¶
type WhileStmtVisitor interface {
Visitor
VisitWhileStmt(*WhileStmt) VisitResult
}
type WhileStmtVisitorFunc ¶
type WhileStmtVisitorFunc func(*WhileStmt) VisitResult
func (WhileStmtVisitorFunc) VisitWhileStmt ¶
func (f WhileStmtVisitorFunc) VisitWhileStmt(stmt *WhileStmt) VisitResult
func (WhileStmtVisitorFunc) Visitor ¶
func (WhileStmtVisitorFunc) Visitor()
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
This file contains an example annotator that attaches metadata to Bad nodes The metadata is a simple counter that is attached to each Bad node
|
This file contains an example annotator that attaches metadata to Bad nodes The metadata is a simple counter that is attached to each Bad node |