Errors specific to the parser package
const ( RightCurvedBracketError string = "Unexpected \")\" [%d]" RightSquareBracketError string = "Unexpected \"]\" [%d]" AtomTypeError string = "Bad Atom type" UnspecifiedAtomError string = "Unspecified Atom error %#v: %#v" )
func NodeName(nodeType NodeType) string
NodeName returns the name of the node for a given node value
CallNode object
type CallNode struct { // Pos NodeType Callee Node Args []Node }
func (node *CallNode) Copy() Node
Copy creates a copy of a call node
func (node *CallNode) String() string
String returns the string value for a call node
IdentNode defines the identity node for use in identity operations
type IdentNode struct { // Pos NodeType Ident string }
func NewIdentNode(name string) *IdentNode
NewIdentNode creates a new identity node
func (node *IdentNode) Copy() Node
Copy creates a copy of an IdentNode instance
func (node *IdentNode) String() string
String returns a string represnetation of IdentNode
Node holds data for parsed AST nodes
type Node interface { Type() NodeType // Position() Pos String() string Copy() Node }
func Parse(l *lexer.Lexer) []Node
Parse takes lexed data and returns a tree of parsed nodes. This function is
a convenience wrapper around ParseAtoms.
func ParseAtom(l *lexer.Lexer, item lexer.Atom, lookingFor rune) (Node, error)
ParseAtom takes a given lexed item, determines its type, and then create a
corresponding and appropriate node for that atom.
func ParseAtoms(l *lexer.Lexer, tree []Node, lookingFor rune) []Node
ParseAtoms iterates over the items in the given lexed data and adds parsed
nodes to the given tree.
func ParseFromString(name, program string) []Node
ParseFromString parses code and returns a collection of nodes.
NodeType defines a dedicated type for node types
type NodeType int
Constants for the parser package
const ( NodeIdent NodeType = iota NodeString NodeNumber NodeCall NodeVector )
func (t NodeType) Type() NodeType
Type is a convenience method for getting the NodeType
NumberNode object
type NumberNode struct { // Pos NodeType Value string NumberType token.Token }
func (node *NumberNode) Copy() Node
Copy creates a copy of a number node
func (node *NumberNode) String() string
String returns the string value for a number node
Pos type
type Pos int
func (p Pos) Position() Pos
Position returns a pos type
StringNode object
type StringNode struct { // Pos NodeType Value string }
func (node *StringNode) Copy() Node
Copy creates a copy of a string node
func (node *StringNode) String() string
String returns the string represnetation of a string node
VectorNode object
type VectorNode struct { // Pos NodeType Nodes []Node }
func (node *VectorNode) Copy() Node
Copy creates a copy of a vector node
func (node *VectorNode) String() string
String returns the string value of a vector node