Documentation ¶
Overview ¶
Package MapAST is an abstract syntax tree for the go language.
Index ¶
- Constants
- Variables
- func AssignStmtNode(kind byte, elemscount uint64) []byte
- func BlocOfCodeNode(kind byte, headelemscount uint64) []byte
- func BranchStmtNode(kind byte) []byte
- func ClosureExpNode(paramscount uint64) []byte
- func Code(print func(string), ast map[uint64][]byte, iterator uint64, parent uint64)
- func Dump(print func(string), ast map[uint64][]byte, iterator uint64, pad int) bool
- func ExpressionNode(kind byte, elemscount uint64) []byte
- func GoDferStmtNode(kind byte) []byte
- func IncDecStmtNode(kind byte) []byte
- func LblGotoCntNode(kind byte) []byte
- func LookupComments(file []byte, EnderSepar [2]map[int]struct{})
- func O(n uint64) uint64
- func Poke(ast map[uint64][]byte, iterator uint64) bool
- func PrintCode(ast map[uint64][]byte, iterator uint64, parent uint64)
- func PrintDump(ast map[uint64][]byte, iterator uint64, pad int) bool
- func Printer(s string)
- func ToplevFuncNode(receiver bool, argc uint64) []byte
- func TypDefStmtNode(kind byte) []byte
- func VarDefStmtNode(kind byte) []byte
- func Which(node []byte) []byte
Constants ¶
const AssignStmtAdd byte = 3
AssignStmtAdd is an assignment with an add assignment operation.
const AssignStmtAnd byte = 8
AssignStmtAnd is an assignment with a bitwise and assignment operation.
const AssignStmtAndNot byte = 2
AssignStmtAndNot is an assignment with an and not assignment operation.
const AssignStmtColonEq byte = 1
AssignStmtColonEq is a short variable declaration
const AssignStmtEqual byte = 0
AssignStmtEqual is an assignment without an assignment operation.
const AssignStmtIotaIsLast byte = 13
AssignStmtIotaIsLast is used for constant declaration for lines that follow the iota row.
const AssignStmtMoreColonEq byte = 16
AssignStmtMoreColonEq is a short variable declaration with one expression on the right hand side.
const AssignStmtMoreColonEqRange byte = 18
AssignStmtMoreColonEqRange is a short variable declaration with one expression on the right hand side. Used within a range loop.
const AssignStmtMoreEqual byte = 15
AssignStmtMoreEqual is an assignment without an assignment operation. It has one expression on the right hand side.
const AssignStmtMoreEqualRange byte = 17
AssignStmtMoreEqualRange is an assignment without an assignment operation. It has one expression on the right hand side. Used within a range loop.
const AssignStmtMul byte = 5
AssignStmtMul is an assignment with a multiply assignment operation.
const AssignStmtOr byte = 9
AssignStmtOr is an assignment with a bitwise or assignment operation.
const AssignStmtQuo byte = 6
AssignStmtQuo is an assignment with a division assignment operation.
const AssignStmtRem byte = 7
AssignStmtRem is an assignment with a remainder assignment operation.
const AssignStmtShl byte = 11
AssignStmtShl is an assignment with a left shift assignment operation.
const AssignStmtShr byte = 12
AssignStmtShr is an assignment with a right shift assignment operation.
const AssignStmtSub byte = 4
AssignStmtSub is an assignment with a subtract assignment operation.
const AssignStmtTotalCount byte = 19
AssignStmtTotalCount is a total count sentinel. Do not use.
const AssignStmtTypeIsLast byte = 14
AssignStmtTypeIsLast is used in variable declaration giving the variables a type but no initial values are assigned.
const AssignStmtXor byte = 10
AssignStmtXor is an assignment with a bitwise xor assignment operation.
const BlocOfCodeCase byte = 8
BlocOfCodeCase contains Expression header elements that will appear comma separated.
const BlocOfCodeCommunicate byte = 11
BlocOfCodeCommunicate is a communicate clause. It has exactly one Expression or AssignStmt node in header. Child of BlocOfCodeSelect.
const BlocOfCodeCommunicateDefault byte = 12
BlocOfCodeCommunicateDefault is a communicate default clause. It has no header entries. Child of BlocOfCodeSelect.
const BlocOfCodeDefault byte = 9
BlocOfCodeDefault is a default clause, child of BlocOfCodeSwitch or a BlocOfCodeTypeSwitch. It has zero header elements.
const BlocOfCodeFor byte = 4
BlocOfCodeFor is "for" or "for something range something" loop. The range (if any) is part of AssignStmt child.
const BlocOfCodeForRange byte = 5
BlocOfCodeForRange is a for range loop. This loop code begins with "for range".
const BlocOfCodeIf byte = 1
BlocOfCodeIf is an if code block. It may occur right after BlocOfCodeIfElse, forming an if else if sequence of blocks. Has 1 or 3 header entries.
const BlocOfCodeIfElse byte = 2
BlocOfCodeIfElse. Must be followed by BlocOfCodePlain or BlocOfCodeIf node.
const BlocOfCodeNone byte = 10
BlocOfCodeNone is unused, but contains elements but no brackets.
const BlocOfCodePlain byte = 0
BlocOfCodePlain is a plain code block. Child of BlocOfCode, ToplevFunc or ClosureExp. Has zero header entries.
const BlocOfCodeSelect byte = 7
BlocOfCodeSelect contains no block header elements. The children are BlocOfCodeCommunicate or BlocOfCodeCommunicateDefault nodes.
const BlocOfCodeSwitch byte = 3
BlocOfCodeSwitch is a non-type switch. Can contain only BlocOfCodeCase and BlocOfCodeDefault nodes.
const BlocOfCodeTotalCount byte = 13
BlocOfCodeTotalCount is a total count sentinel. Do not use.
const BlocOfCodeTypeSwitch byte = 6
BlocOfCodeTypeSwitch switches using a .(type) header Expression.
const BranchStmtBreak byte = 1
BranchStmtSemi is a break statement. Child of a BlocOfCode node. Does not refer to a label.
const BranchStmtContinue byte = 2
BranchStmtContinue is a continue statement. Child of a BlocOfCode node. Does not refer to a label.
const BranchStmtFallthrough byte = 3
BranchStmtFallthrough is a fallthrough statement. Child of a BlocOfCode node.
const BranchStmtGoto byte = 4
BranchStmtGoto is a goto statement. Child of a BlocOfCode node. Does not refer to a label.
const BranchStmtSemi byte = 0
BranchStmtSemi is an explicit semicolon. Child of a BlocOfCode node.
const CommentRowEnder byte = 0
CommentRowEnder is a comment starting at the end of a previous element line.
const CommentRowNormal byte = 1
CommentRowNormal is a comment occupying it's own row.
const CommentRowSeparate byte = 2
CommentRowSeparate is a comment following an empty line(s).
const ExpressionAnd byte = 16
ExpressionAnd is a bitwise and operator.
const ExpressionAndAnd byte = 2
ExpressionAndAnd is a boolean and operator.
const ExpressionAndNot byte = 17
ExpressionAndNot is a bitwise and not operator.
const ExpressionArrayType byte = 26
ExpressionArrayType is an array type.
const ExpressionArrow byte = 25
ExpressionArrow is a send statement or an unary receive operation.
const ExpressionBrackets byte = 0
ExpressionBrackets has exactly one child that appears in a round brackets.
const ExpressionCall byte = 24
ExpressionCall is a call or method call expression, it is not variadic.
const ExpressionCallDotDotDot byte = 30
ExpressionCall is a variadic call or method call expression.
const ExpressionChan byte = 35
ExpressionChan is a channel type without a direction arrow operator.
const ExpressionComposed byte = 31
ExpressionComposed is a Literal Value nested in a composite literal.
const ExpressionComposite byte = 23
ExpressionComposite is a composite literal.
const ExpressionDiv byte = 14
ExpressionDiv is a numeric divide operator.
const ExpressionDot byte = 21
ExpressionDot is a dot separated selector expression or a qualified identifier.
const ExpressionEqual byte = 3
ExpressionEqual is an equality operator.
const ExpressionGrtEq byte = 7
ExpressionGrtEq is a numeric greater than or equal operator.
const ExpressionGrtThan byte = 8
ExpressionGrtThan is a numeric greater than operator.
const ExpressionIdentifier byte = 34
ExpressionIdentifier is a string wrapper. It has one string child node.
const ExpressionInChan byte = 36
ExpressionInChan is a channel type with a send direction arrow operator.
const ExpressionIndex byte = 32
ExpressionIndex is an index expression.
const ExpressionKeyVal byte = 28
ExpressionKeyVal is a key value expression.
const ExpressionLSh byte = 18
ExpressionLSh is a numeric left shift operator.
const ExpressionLessEq byte = 6
ExpressionLessEq is a numeric less than or equal operator.
const ExpressionLessThan byte = 5
ExpressionLessThan is a numeric less than operator.
const ExpressionMap byte = 33
ExpressionMap is a map type
const ExpressionMinus byte = 10
ExpressionMinus is a numeric minus operator.
const ExpressionMod byte = 15
ExpressionMod is a numeric remainder operator.
const ExpressionMul byte = 13
ExpressionMul is a numeric multiply operator.
const ExpressionNot byte = 20
ExpressionAndAnd is a boolean not operator.
const ExpressionNotEq byte = 4
ExpressionNotEq is an inequality operator.
const ExpressionOr byte = 11
ExpressionOr is a bitwise or operator.
const ExpressionOrOr byte = 1
ExpressionOrOr is a boolean or operator.
const ExpressionOutChan byte = 37
ExpressionOutChan is a channel type with a receive direction arrow operator.
const ExpressionPlus byte = 9
ExpressionPlus is a numeric plus operator.
const ExpressionRSh byte = 19
ExpressionRSh is a numeric right shift operator.
const ExpressionSlice byte = 22
ExpressionSlice is a slice expression.
const ExpressionSliceType byte = 27
ExpressionSliceType is a slice type.
const ExpressionTotalCount byte = 38
ExpressionTotalCount is a total count sentinel. Do not use.
const ExpressionType byte = 29
ExpressionType is a binary type assertion. If unary, it asserts the reserved word type.
const ExpressionXor byte = 12
ExpressionXor is a bitwise xor operator.
const GoDferStmtDefer byte = 1
GoDferStmtDefer is a defer statement used to invoke a call Expression using the go or defer keyword. It's only child is the Expression to be invoked.
const GoDferStmtGo byte = 0
GoDferStmtGo is a go statement used to invoke a call Expression using the go or defer keyword. It's only child is the Expression to be invoked.
const IncDecStmtMinusMinus byte = 1
IncDecStmtMinusMinus is an IncDec statement. It's the decrement -- statement.
const IncDecStmtPlusPlus byte = 0
IncDecStmtPlusPlus is an IncDec statement. It's the increment ++ statement.
const LblGotoCntBreak byte = 3
LblGotoCntBreak is a break followed by a label.
const LblGotoCntContinue byte = 2
LblGotoCntContinue is a continue followed by a label.
const LblGotoCntGoto byte = 1
LblGotoCntGoto is a goto followed by a label.
const LblGotoCntLabel byte = 0
LblGotoCntLabel is a labeled statement followed by a colon.
const MaxSubnodes = 1000000
MaxSubnodes - The current limit of how many certain type subnodes can some nodes have.
const PackageDefNormal byte = 0
PackageDefNormal is a package statement not following an empty line(s).
const PackageDefSeparate byte = 1
PackageDefSeparate is a package statement separated by an empty line(s).
const TypDefStmtAlias byte = 1
TypDefStmtAlias contains alias declaration.
const TypDefStmtNormal byte = 0
TypDefStmtNormal contains type definition.
const TypedIdentEllipsis byte = 2
TypedIdentEllipsis is the names followed by an ellipsis followed by a type.
const TypedIdentEquals byte = 1
TypedIdentEquals is the names followed by an equal sign followed by a type.
const TypedIdentNormal byte = 0
TypedIdentNormal is the names followed by type.
const TypedIdentTagged byte = 3
TypedIdentTagged is the names followed by type followed by a string tag.
const VarDefStmtConst byte = 1
VarDefStmtConst is a standalone or a multiple constant declaration.
const VarDefStmtTotalCount byte = 2
VarDefStmtTotalCount is a total count sentinel. Do not use.
const VarDefStmtVar byte = 0
VarDefStmtVar is a standalone or a multiple variable declaration.
Variables ¶
var AssignStmt = storage[48:]
AssignStmt contains left hand side entries followed by an optional RootOfType and implicit equality kind operator, followed by a right hand side entries.
var BlocOfCode = storage[16:]
BlocOfCode node holds statements or other BlocOfCode nodes. Some BlocOfCode kinds have a header followed by the opening brace. Other BlocOfCode kinds lack braces altogether and use colon instead.
var BranchStmt = []byte("BranchStmt")
BranchStmt is a sole statement. One of semicolon, break, continue, fallthrough, goto. It has no children.
var ClosureExp = storage[64:]
ClosureExp is a function literal. The children are TypedIdent nodes.
var CommentRow = []byte("CommentRow")
CommentRow contains exactly one string, holding the comment verbatim, with optional leading or trailing newlines.
var Expression = storage[0:]
Expression node is one of the 38 differend kinds of Expression. It contains strings, IfceTypExps, ClosureExps, StructTypes or more Expressions.
var FileMatter = []byte("FileMatter")
FileMatter contains the file block elements. It represents a single go file. FileMatter node is a child of RootMatter node.
var GenericExp = []byte("GenericExp")
GenericExp is a generic type node. This node is reserved for future use.
var GoDferStmt = []byte("GoDferStmt")
GoDferStmt node is a statement node used to invoke a call Expression using the go or defer keyword. It's only child is the Expression to be invoked.
var IfceMethod = storage[80:]
IfceMethod node is a child of IfceTypExp. It's children are TypedIdent nodes. The name of interface method is stored in the first TypedIdent child, the one that would otherwise work as a receiver field.
var IfceTypExp = []byte("IfceTypExp")
IfceTypExp node contains one or several IfceMethod or RootOfType nodes.
var ImportStmt = []byte("ImportStmt")
ImportStmt holds a single import declaration. It is a child of ImportsDef or of a FileMatter. If the parent is FileMatter, it is a standalone import declaration. ImportStmt contains one or two strings.
var ImportsDef = []byte("ImportsDef")
ImportsDef is a bracketed container for multiple ImportStmt nodes. It is a child of FileMatter.
var IncDecStmt = []byte("IncDecStmt")
IncDecStmt is an increment++ or decrement-- statement. It's only child is a string identifier or a more complex Expression.
var LblGotoCnt = []byte("LblGotoCnt")
LblGotoCnt is a labeled statement, or a statement that uses label: break, continue or goto statement. It has one child, the string known as label name.
var PackageDef = []byte("PackageDef")
PackageDef is a child of FileMatter. Contains a string holding the file package name, and an optional CommentRow containing the import comment.
var ReturnStmt = []byte("ReturnStmt")
ReturnStmt node is a return statement followed by it's children. Strings are not allowed, a string child must be wrapped by ExpressionIdentifier.
var RootMatter = []byte("RootMatter")
RootMatter node is equivalent to a package block or an universe block containing all Go source text contained within the map. There is only one RootMatter located at key zero (0).
var RootOfType = []byte("RootOfType")
RootOfType marks the root of the type expression tree. It's only child is usually an Expression.
var StructType = []byte("StructType")
StructType is a sequence of named elements, called fields. Some fields can share their type, using a TypedIdent node.
var ToplevFunc = storage[32:]
ToplevFunc is a child function of FileMatter. The first child is a string. The rest of children can be TypedIdent nodes. The trailing child is an optional BlocOfCode.
var TypDefStmt = []byte("TypDefStmt")
TypDefStmt type declaration allows to declare an alias or a type. Bracketed form is currently not available.
var TypedIdent = []byte("TypedIdent")
TypedIdent field contains several string identifiers known as names, followed by a RootOfType node representing the type shared by the named identifiers. If contained within a StructType, it can be optionally tagged using the last string child (the tag).
var VarDefStmt = []byte("VarDefStmt")
VarDefStmt is a standalone or a multiple variable or constant declaration. It's children are single or multiple AssignStmt nodes, one for each row.
Functions ¶
func AssignStmtNode ¶
Constructor for AssignStmt node. Elemscount is the number of elements including both side elements and the central type node (if any).
func BlocOfCodeNode ¶
Constructor for BlocOfCode node. Headelemscount is the count of header elements including semicolons.
func ClosureExpNode ¶
Constructor for ClosureExp node. Paramscount is the number of parameters.
func Dump ¶
Dump prints an ast dump. This is a xml like output that can be used to debug to see if the ast is correct. Only nested nodes under iterator position are printed.
func ExpressionNode ¶
Constructor for Expression node. Elemscount is the number of children elements.
func LookupComments ¶
LookupComments fills EnderSepar with comment location information from file. This information is necessary to recognize comments of various types, like comments that span end of line only, or comments that follow an empty lines.
func O ¶
O is an one way function. Given a node key it calculates the key of its first child node. The other keys of child nodes follow by adding 1, 2, 3... to the result.
func PrintDump ¶
PrintDump prints an ast dump. This a is xml like output that can be used to debug to see if the ast is correct. Only nested nodes under iterator position are printed.
func Printer ¶
func Printer(s string)
Printer is used to print strings to standard error. Empty strings are printed as if they were newlines.
func ToplevFuncNode ¶
Constructor for ToplevFunc node. Argc is the count of proper arguments excluding results and receiver.
Types ¶
This section is empty.