Documentation ¶
Overview ¶
Package ast defines spok's abstract syntax tree.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assign ¶
type Assign struct { Value Node // The value it's set to Name Ident // The name of the identifier NodeType }
Assign holds a global variable assignment.
type Comment ¶
Comment holds a comment.
type Function ¶
type Function struct { Name Ident // Function name Arguments []Node // Functions arguments NodeType }
Function holds a spok builtin function e.g. 'exec' or 'join'.
type Ident ¶
Ident holds an identifier.
type Node ¶
type Node interface { Type() NodeType // Return the type of the current node. String() string // Pretty print the node. Literal() string // The go literal representation of the node, saves us from using type conversion. Write(s *strings.Builder) // Write the formatted syntax back out to a builder. }
Node is an element in the AST.
type NodeType ¶
type NodeType int
NodeType identifies the type of an AST node.
const ( NodeComment NodeType = iota // A spok comment, preceded by a '#'. NodeIdent // An identifier e.g. global variable or name of a task. NodeAssign // A global variable assignment. NodeString // A quoted string literal e.g "hello". NodeFunction // A spok builtin function e.g. exec NodeTask // A spok task. NodeCommand // A spok task command. )
type String ¶
String holds a string.
func (String) Literal ¶
Literal returns the go literal value of the string, usable in source code e.g. "hello".
type Task ¶
type Task struct { Name Ident // The name of the task Docstring Comment // Task docstring comment Dependencies []Node // Task dependencies Outputs []Node // Task outputs Commands []Command // Shell commands to run NodeType }
Task holds a spok task.
type Tree ¶
type Tree struct {
Nodes []Node // List of all AST nodes.
}
Tree represents the entire AST for a spokfile.
Click to show internal directories.
Click to hide internal directories.