Documentation
¶
Index ¶
- func IsExternFunc(fun *FuncDecl) bool
- func IsGlobalScope(table *SymbolTable) bool
- func IterateImportedDecls(imprt *ImportStmt, ...)
- func IterateModuleImports(module *Module, fun func(*Module))
- func TrimStringLit(lit *token.Token) string
- func VisitAst(ast *Ast, visitor BaseVisitor)
- func VisitModuleRec(module *Module, visitor BaseVisitor)
- func VisitNode(visitor BaseVisitor, node Node, currentScope *SymbolTable)
- func WalkAst(ast *Ast, visitor FullVisitor)
- type Alias
- type AssignStmt
- type AssignStmtVisitor
- type Assigneable
- type Ast
- 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 BadExpr
- type BadExprVisitor
- type BadStmt
- type BadStmtVisitor
- type BaseVisitor
- type BinaryExpr
- type BinaryExprVisitor
- type BinaryOperator
- type BlockStmt
- type BlockStmtVisitor
- type BoolLit
- type BoolLitVisitor
- type BreakContineStmtVisitor
- type BreakContinueStmt
- type CastExpr
- type CastExprVisitor
- type CharLit
- type CharLitVisitor
- type ConditionalVisitor
- type DeclStmt
- type DeclStmtVisitor
- type Declaration
- type ExprStmt
- type ExprStmtVisitor
- type Expression
- type FieldAccess
- type FieldAccessVisitor
- type FloatLit
- type FloatLitVisitor
- type ForRangeStmt
- type ForRangeStmtVisitor
- type ForStmt
- type ForStmtVisitor
- type FullVisitor
- type FuncAlias
- type FuncCall
- type FuncCallVisitor
- 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 Grouping
- type GroupingVisitor
- type Ident
- type IdentVisitor
- type IfStmt
- type IfStmtVisitor
- type ImportStmt
- type ImportStmtVisitor
- type Indexing
- type IndexingVisitor
- type IntLit
- type IntLitVisitor
- type ListLit
- type ListLitVisitor
- type Module
- type Node
- type Operator
- type ReturnStmt
- type ReturnStmtVisitor
- type ScopeVisitor
- type SetupableVisitor
- type Statement
- type StringLit
- type StringLitVisitor
- 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 StructLiteral
- type StructLiteralVisitor
- type SymbolTable
- type TernaryExpr
- type TernaryExprVisitor
- type TernaryOperator
- type UnaryExpr
- type UnaryExprVisitor
- 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 VisitResult
- type WhileStmt
- type WhileStmtVisitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsExternFunc ¶
check if the function is defined externally
func IsGlobalScope ¶
func IsGlobalScope(table *SymbolTable) bool
returns wether table is the global scope table.Enclosing == nil
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 VisitAst ¶
func VisitAst(ast *Ast, visitor BaseVisitor)
invokes visitor on each Node of ast while checking if visitor implements other *Visitor-Interfaces and invoking them accordingly
func VisitModuleRec ¶
func VisitModuleRec(module *Module, visitor BaseVisitor)
calls VisitAst on all Asts of module and it's imports
func VisitNode ¶
func VisitNode(visitor BaseVisitor, node Node, currentScope *SymbolTable)
invokes visitor on each Node of ast while checking if visitor implements other *Visitor-Interfaces and invoking them accordingly a optional SymbolTable may be passed if neccessery
func WalkAst ¶
func WalkAst(ast *Ast, visitor FullVisitor)
invoke the Visitor for each top level statement in the Ast
Types ¶
type Alias ¶
type Alias interface {
// tokens of the alias
GetTokens() []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 AssignStmt ¶
type AssignStmt struct {
Range token.Range
Tok token.Token
Var Assigneable // the variable to assign to
Rhs Expression // literal assign value
}
Statements
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 {
BaseVisitor
VisitAssignStmt(*AssignStmt) VisitResult
}
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)
}
represents an Abstract Syntax Tree for a token.DDP program
type BadDecl ¶
an invalid Declaration
func (*BadDecl) Accept ¶
func (decl *BadDecl) Accept(visitor FullVisitor) VisitResult
type BadDeclVisitor ¶
type BadDeclVisitor interface {
BaseVisitor
VisitBadDecl(*BadDecl) VisitResult
}
type BadExpr ¶
Expressions
func (*BadExpr) Accept ¶
func (expr *BadExpr) Accept(v FullVisitor) VisitResult
type BadExprVisitor ¶
type BadExprVisitor interface {
BaseVisitor
VisitBadExpr(*BadExpr) VisitResult
}
type BadStmt ¶
Statements
func (*BadStmt) Accept ¶
func (stmt *BadStmt) Accept(v FullVisitor) VisitResult
type BadStmtVisitor ¶
type BadStmtVisitor interface {
BaseVisitor
VisitBadStmt(*BadStmt) VisitResult
}
type BaseVisitor ¶
type BaseVisitor interface {
BaseVisitor() // dummy function for the interface
}
type BinaryExpr ¶
type BinaryExpr struct {
Range token.Range
Tok token.Token
Lhs Expression
Operator BinaryOperator
Rhs Expression
}
Expressions
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 {
BaseVisitor
VisitBinaryExpr(*BinaryExpr) VisitResult
}
type BinaryOperator ¶
type BinaryOperator int
const ( BIN_INVALID BinaryOperator = iota BIN_AND // und BIN_OR // 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
}
Statements
func (*BlockStmt) Accept ¶
func (stmt *BlockStmt) Accept(v FullVisitor) VisitResult
type BlockStmtVisitor ¶
type BlockStmtVisitor interface {
BaseVisitor
VisitBlockStmt(*BlockStmt) VisitResult
}
type BoolLit ¶
Expressions
func (*BoolLit) Accept ¶
func (expr *BoolLit) Accept(v FullVisitor) VisitResult
type BoolLitVisitor ¶
type BoolLitVisitor interface {
BaseVisitor
VisitBoolLit(*BoolLit) VisitResult
}
type BreakContineStmtVisitor ¶
type BreakContineStmtVisitor interface {
BaseVisitor
VisitBreakContinueStmt(*BreakContinueStmt) VisitResult
}
type BreakContinueStmt ¶
type BreakContinueStmt struct {
Range token.Range
Tok token.Token // VERLASSE for break, otherwise continue
}
Statements
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 CastExpr ¶
type CastExpr struct {
Range token.Range
Type ddptypes.Type
Lhs Expression
}
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 {
BaseVisitor
VisitCastExpr(*CastExpr) VisitResult
}
type CharLit ¶
Expressions
func (*CharLit) Accept ¶
func (expr *CharLit) Accept(v FullVisitor) VisitResult
type CharLitVisitor ¶
type CharLitVisitor interface {
BaseVisitor
VisitCharLit(*CharLit) VisitResult
}
type ConditionalVisitor ¶
type DeclStmt ¶
type DeclStmt struct {
Decl Declaration
}
Statements
func (*DeclStmt) Accept ¶
func (stmt *DeclStmt) Accept(v FullVisitor) VisitResult
type DeclStmtVisitor ¶
type DeclStmtVisitor interface {
BaseVisitor
VisitDeclStmt(*DeclStmt) VisitResult
}
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
}
Statements
func (*ExprStmt) Accept ¶
func (stmt *ExprStmt) Accept(v FullVisitor) VisitResult
type ExprStmtVisitor ¶
type ExprStmtVisitor interface {
BaseVisitor
VisitExprStmt(*ExprStmt) VisitResult
}
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 {
BaseVisitor
VisitFieldAccess(*FieldAccess) VisitResult
}
type FloatLit ¶
Expressions
func (*FloatLit) Accept ¶
func (expr *FloatLit) Accept(v FullVisitor) VisitResult
type FloatLitVisitor ¶
type FloatLitVisitor interface {
BaseVisitor
VisitFloatLit(*FloatLit) VisitResult
}
type ForRangeStmt ¶
type ForRangeStmt struct {
Range token.Range
For token.Token // Für
Initializer *VarDecl // InitVal is the same pointer as In
In Expression // the string/list to range over
Body *BlockStmt
}
Statements
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 {
BaseVisitor
VisitForRangeStmt(*ForRangeStmt) VisitResult
}
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
}
Statements
func (*ForStmt) Accept ¶
func (stmt *ForStmt) Accept(v FullVisitor) VisitResult
type ForStmtVisitor ¶
type ForStmtVisitor interface {
BaseVisitor
VisitForStmt(*ForStmt) VisitResult
}
type FullVisitor ¶
type FullVisitor interface {
BaseVisitor
BadDeclVisitor
VarDeclVisitor
FuncDeclVisitor
StructDeclVisitor
BadExprVisitor
IdentVisitor
IndexingVisitor
FieldAccessVisitor
IntLitVisitor
FloatLitVisitor
BoolLitVisitor
CharLitVisitor
StringLitVisitor
ListLitVisitor
UnaryExprVisitor
BinaryExprVisitor
TernaryExprVisitor
CastExprVisitor
GroupingVisitor
FuncCallVisitor
StructLiteralVisitor
BadStmtVisitor
DeclStmtVisitor
ExprStmtVisitor
ImportStmtVisitor
AssignStmtVisitor
BlockStmtVisitor
IfStmtVisitor
WhileStmtVisitor
ForStmtVisitor
ForRangeStmtVisitor
BreakContineStmtVisitor
ReturnStmtVisitor
}
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)
}
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
}
Expressions
func (*FuncCall) Accept ¶
func (expr *FuncCall) Accept(v FullVisitor) VisitResult
type FuncCallVisitor ¶
type FuncCallVisitor interface {
BaseVisitor
VisitFuncCall(*FuncCall) VisitResult
}
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
Mod *Module // the module in which the function was declared
ParamNames []token.Token // x, y und z
ParamTypes []ddptypes.ParameterType // type, and wether the argument is a reference
ParamComments []*token.Token // comments for the parameters, the slice or its elements may be nil
Type ddptypes.Type // return Type, Zahl Kommazahl nichts ...
Body *BlockStmt // nil for extern functions
ExternFile token.Token // string literal with filepath (only pesent if Body is nil)
Aliases []*FuncAlias
}
Declarations
func (*FuncDecl) Accept ¶
func (decl *FuncDecl) Accept(visitor FullVisitor) VisitResult
type FuncDeclVisitor ¶
type FuncDeclVisitor interface {
BaseVisitor
VisitFuncDecl(*FuncDecl) VisitResult
}
type Grouping ¶
type Grouping struct {
Range token.Range
LParen token.Token // (
Expr Expression
}
Expressions
func (*Grouping) Accept ¶
func (expr *Grouping) Accept(v FullVisitor) VisitResult
type GroupingVisitor ¶
type GroupingVisitor interface {
BaseVisitor
VisitGrouping(*Grouping) VisitResult
}
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 *VarDecl
}
Expressions
func (*Ident) Accept ¶
func (expr *Ident) Accept(v FullVisitor) VisitResult
type IdentVisitor ¶
type IdentVisitor interface {
BaseVisitor
VisitIdent(*Ident) VisitResult
}
type IfStmt ¶
type IfStmt struct {
Range token.Range
If token.Token // wenn/aber
Condition Expression
Then Statement
Else Statement
}
Statements
func (*IfStmt) Accept ¶
func (stmt *IfStmt) Accept(v FullVisitor) VisitResult
type IfStmtVisitor ¶
type IfStmtVisitor interface {
BaseVisitor
VisitIfStmt(*IfStmt) VisitResult
}
type ImportStmt ¶
type ImportStmt struct {
Range token.Range
// the string literal which specified the filename
FileName token.Token
// the module that was imported because of this
// nil if it does not exist or a similar error occured while importing
Module *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) String ¶
func (stmt *ImportStmt) String() string
func (*ImportStmt) Token ¶
func (stmt *ImportStmt) Token() token.Token
type ImportStmtVisitor ¶
type ImportStmtVisitor interface {
BaseVisitor
VisitImportStmt(*ImportStmt) VisitResult
}
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 {
BaseVisitor
VisitIndexing(*Indexing) VisitResult
}
type IntLit ¶
Expressions
func (*IntLit) Accept ¶
func (expr *IntLit) Accept(v FullVisitor) VisitResult
type IntLitVisitor ¶
type IntLitVisitor interface {
BaseVisitor
VisitIntLit(*IntLit) VisitResult
}
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
}
Expressions
func (*ListLit) Accept ¶
func (expr *ListLit) Accept(v FullVisitor) VisitResult
type ListLitVisitor ¶
type ListLitVisitor interface {
BaseVisitor
VisitListLit(*ListLit) VisitResult
}
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
// 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
}
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 Node ¶
type Node interface {
fmt.Stringer
Token() token.Token
GetRange() token.Range
Accept(FullVisitor) VisitResult
}
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
type ReturnStmt ¶
type ReturnStmt struct {
Range token.Range
Return token.Token // Gib
Func string
Value Expression // nil for void return
}
Statements
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 {
BaseVisitor
VisitReturnStmt(*ReturnStmt) VisitResult
}
type ScopeVisitor ¶
type ScopeVisitor interface {
UpdateScope(*SymbolTable)
}
type SetupableVisitor ¶
type SetupableVisitor interface {
BaseVisitor
// called before the first node is visited
// the passed visitor is the actual implementation that forwards the visits
// and can be saved to customize visit order
//
// should return true if the visitor should start visiting
Setup(FullVisitor) bool
}
a visitor that can be setup before visiting
type Statement ¶
type Statement interface {
Node
// contains filtered or unexported methods
}
basic Node interfaces
type StringLit ¶
Expressions
func (*StringLit) Accept ¶
func (expr *StringLit) Accept(v FullVisitor) VisitResult
type StringLitVisitor ¶
type StringLitVisitor interface {
BaseVisitor
VisitStringLit(*StringLit) VisitResult
}
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)
}
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) 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.StructType // the type resulting from this decl
Aliases []*StructAlias // the constructors of the struct
}
Declarations
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 {
BaseVisitor
VisitStructDecl(*StructDecl) VisitResult
}
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 arguments passed to the literal
// this does not include all struct fields,
// only the ones needed by the alias used
Args map[string]Expression
}
Expressions
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 {
BaseVisitor
VisitStructLiteral(*StructLiteral) VisitResult
}
type SymbolTable ¶
type SymbolTable struct {
Enclosing *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 NewSymbolTable ¶
func NewSymbolTable(enclosing *SymbolTable) *SymbolTable
func (*SymbolTable) InsertDecl ¶
func (scope *SymbolTable) 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 (*SymbolTable) LookupDecl ¶
func (scope *SymbolTable) 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)
type TernaryExpr ¶
type TernaryExpr struct {
Range token.Range
Tok token.Token
Lhs Expression
Mid Expression
Rhs Expression
Operator TernaryOperator
}
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 {
BaseVisitor
VisitTernaryExpr(*TernaryExpr) VisitResult
}
type TernaryOperator ¶
type TernaryOperator int
const ( TER_INVALID TernaryOperator = iota TER_SLICE // von bis TER_BETWEEN // zwischen )
func (TernaryOperator) Operator ¶
func (TernaryOperator) Operator()
func (TernaryOperator) String ¶
func (op TernaryOperator) String() string
type UnaryExpr ¶
type UnaryExpr struct {
Range token.Range
Tok token.Token
Operator UnaryOperator
Rhs Expression
}
Expressions
func (*UnaryExpr) Accept ¶
func (expr *UnaryExpr) Accept(v FullVisitor) VisitResult
type UnaryExprVisitor ¶
type UnaryExprVisitor interface {
BaseVisitor
VisitUnaryExpr(*UnaryExpr) VisitResult
}
type UnaryOperator ¶
type UnaryOperator int
const ( UN_INVALID UnaryOperator = iota UN_ABS // Betrag von UN_LEN // Länge von UN_SIZE // Größe 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
IsPublic bool // wether the function is marked with öffentliche
Mod *Module // the module in which the variable was declared
InitVal Expression // initial value
}
Declarations
func (*VarDecl) Accept ¶
func (decl *VarDecl) Accept(visitor FullVisitor) VisitResult
type VarDeclVisitor ¶
type VarDeclVisitor interface {
BaseVisitor
VisitVarDecl(*VarDecl) VisitResult
}
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 WhileStmt ¶
type WhileStmt struct {
Range token.Range
While token.Token // solange, mache, mal
Condition Expression
Body Statement
}
Statements
func (*WhileStmt) Accept ¶
func (stmt *WhileStmt) Accept(v FullVisitor) VisitResult
type WhileStmtVisitor ¶
type WhileStmtVisitor interface {
BaseVisitor
VisitWhileStmt(*WhileStmt) VisitResult
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
The resolver package should not be used independently from the parser.
|
The resolver package should not be used independently from the parser. |