parse

Imports

Imports #

"fmt"
"strings"
"unicode"
"unicode/utf8"
"fmt"
"strconv"
"strings"
"bytes"
"fmt"
"runtime"
"strconv"
"strings"

Constants & Variables

NodeAction const #

const NodeAction

NodeBool const #

const NodeBool

NodeBreak const #

const NodeBreak

NodeChain const #

const NodeChain

NodeCommand const #

const NodeCommand

NodeComment const #

const NodeComment

NodeContinue const #

const NodeContinue

NodeDot const #

const NodeDot

NodeField const #

const NodeField

NodeIdentifier const #

const NodeIdentifier

NodeIf const #

const NodeIf

NodeList const #

const NodeList

NodeNil const #

const NodeNil

NodeNumber const #

const NodeNumber

NodePipe const #

const NodePipe

NodeRange const #

const NodeRange

NodeString const #

const NodeString

NodeTemplate const #

const NodeTemplate

NodeText const #

const NodeText NodeType = iota

NodeVariable const #

const NodeVariable

NodeWith const #

const NodeWith

ParseComments const #

const ParseComments Mode = *ast.BinaryExpr

SkipFuncCheck const #

const SkipFuncCheck

eof const #

const eof = *ast.UnaryExpr

itemAssign const #

const itemAssign

itemBlock const #

const itemBlock

itemBool const #

const itemBool

itemBreak const #

const itemBreak

itemChar const #

const itemChar

itemCharConstant const #

const itemCharConstant

itemComment const #

const itemComment

itemComplex const #

const itemComplex

itemContinue const #

const itemContinue

itemDeclare const #

const itemDeclare

itemDefine const #

const itemDefine

itemDot const #

const itemDot

itemEOF const #

const itemEOF

itemElse const #

const itemElse

itemEnd const #

const itemEnd

itemError const #

const itemError itemType = iota

itemField const #

const itemField

itemIdentifier const #

const itemIdentifier

itemIf const #

const itemIf

itemKeyword const #

Keywords appear after all the rest.

const itemKeyword

itemLeftDelim const #

const itemLeftDelim

itemLeftParen const #

const itemLeftParen

itemNil const #

const itemNil

itemNumber const #

const itemNumber

itemPipe const #

const itemPipe

itemRange const #

const itemRange

itemRawString const #

const itemRawString

itemRightDelim const #

const itemRightDelim

itemRightParen const #

const itemRightParen

itemSpace const #

const itemSpace

itemString const #

const itemString

itemTemplate const #

const itemTemplate

itemText const #

const itemText

itemVariable const #

const itemVariable

itemWith const #

const itemWith

key var #

var key = map[string]itemType{...}

leftComment const #

const leftComment = "/*"

leftDelim const #

const leftDelim = "{{"

nodeElse const #

const nodeElse

nodeEnd const #

const nodeEnd

rightComment const #

const rightComment = "*/"

rightDelim const #

const rightDelim = "}}"

spaceChars const #

Trimming spaces. If the action begins "{{- " rather than "{{", then all space/tab/newlines preceding the action are trimmed; conversely if it ends " -}}" the leading spaces are trimmed. This is done entirely in the lexer; the parser never sees it happen. We require an ASCII space (' ', \t, \r, \n) to be present to avoid ambiguity with things like "{{-3}}". It reads better with the space present anyway. For simplicity, only ASCII does the job.

const spaceChars = " \t\r\n"

textFormat var #

var textFormat = "%s"

trimMarker const #

Trimming spaces. If the action begins "{{- " rather than "{{", then all space/tab/newlines preceding the action are trimmed; conversely if it ends " -}}" the leading spaces are trimmed. This is done entirely in the lexer; the parser never sees it happen. We require an ASCII space (' ', \t, \r, \n) to be present to avoid ambiguity with things like "{{-3}}". It reads better with the space present anyway. For simplicity, only ASCII does the job.

const trimMarker = '-'

trimMarkerLen const #

Trimming spaces. If the action begins "{{- " rather than "{{", then all space/tab/newlines preceding the action are trimmed; conversely if it ends " -}}" the leading spaces are trimmed. This is done entirely in the lexer; the parser never sees it happen. We require an ASCII space (' ', \t, \r, \n) to be present to avoid ambiguity with things like "{{-3}}". It reads better with the space present anyway. For simplicity, only ASCII does the job.

const trimMarkerLen = *ast.CallExpr

Type Aliases

Mode type #

A mode value is a set of flags (or 0). Modes control parser behavior.

type Mode uint

NodeType type #

NodeType identifies the type of a parse tree node.

type NodeType int

Pos type #

Pos represents a byte position in the original input text from which this template was parsed.

type Pos int

itemType type #

itemType identifies the type of lex items.

type itemType int

stateFn type #

stateFn represents the state of the scanner as a function that returns the next state.

type stateFn func(*lexer) stateFn

Interfaces

Node interface #

A Node is an element in the parse tree. The interface is trivial. The interface contains an unexported method so that only types local to this package can satisfy it.

type Node interface {
Type() NodeType
String() string
Copy() Node
Position() Pos
tree() *Tree
writeTo(*strings.Builder)
}

Structs

ActionNode struct #

ActionNode holds an action (something bounded by delimiters). Control actions have their own nodes; ActionNode represents simple ones such as field evaluations and parenthesized pipelines.

type ActionNode struct {
NodeType
Pos
tr *Tree
Line int
Pipe *PipeNode
}

BoolNode struct #

BoolNode holds a boolean constant.

type BoolNode struct {
NodeType
Pos
tr *Tree
True bool
}

BranchNode struct #

BranchNode is the common representation of if, range, and with.

type BranchNode struct {
NodeType
Pos
tr *Tree
Line int
Pipe *PipeNode
List *ListNode
ElseList *ListNode
}

BreakNode struct #

BreakNode represents a {{break}} action.

type BreakNode struct {
tr *Tree
NodeType
Pos
Line int
}

ChainNode struct #

ChainNode holds a term followed by a chain of field accesses (identifier starting with '.'). The names may be chained ('.x.y'). The periods are dropped from each ident.

type ChainNode struct {
NodeType
Pos
tr *Tree
Node Node
Field []string
}

CommandNode struct #

CommandNode holds a command (a pipeline inside an evaluating action).

type CommandNode struct {
NodeType
Pos
tr *Tree
Args []Node
}

CommentNode struct #

CommentNode holds a comment.

type CommentNode struct {
NodeType
Pos
tr *Tree
Text string
}

ContinueNode struct #

ContinueNode represents a {{continue}} action.

type ContinueNode struct {
tr *Tree
NodeType
Pos
Line int
}

DotNode struct #

DotNode holds the special identifier '.'.

type DotNode struct {
NodeType
Pos
tr *Tree
}

FieldNode struct #

FieldNode holds a field (identifier starting with '.'). The names may be chained ('.x.y'). The period is dropped from each ident.

type FieldNode struct {
NodeType
Pos
tr *Tree
Ident []string
}

IdentifierNode struct #

IdentifierNode holds an identifier.

type IdentifierNode struct {
NodeType
Pos
tr *Tree
Ident string
}

IfNode struct #

IfNode represents an {{if}} action and its commands.

type IfNode struct {
BranchNode
}

ListNode struct #

ListNode holds a sequence of nodes.

type ListNode struct {
NodeType
Pos
tr *Tree
Nodes []Node
}

NilNode struct #

NilNode holds the special identifier 'nil' representing an untyped nil constant.

type NilNode struct {
NodeType
Pos
tr *Tree
}

NumberNode struct #

NumberNode holds a number: signed or unsigned integer, float, or complex. The value is parsed and stored under all the types that can represent the value. This simulates in a small amount of code the behavior of Go's ideal constants.

type NumberNode struct {
NodeType
Pos
tr *Tree
IsInt bool
IsUint bool
IsFloat bool
IsComplex bool
Int64 int64
Uint64 uint64
Float64 float64
Complex128 complex128
Text string
}

PipeNode struct #

PipeNode holds a pipeline with optional declaration

type PipeNode struct {
NodeType
Pos
tr *Tree
Line int
IsAssign bool
Decl []*VariableNode
Cmds []*CommandNode
}

RangeNode struct #

RangeNode represents a {{range}} action and its commands.

type RangeNode struct {
BranchNode
}

StringNode struct #

StringNode holds a string constant. The value has been "unquoted".

type StringNode struct {
NodeType
Pos
tr *Tree
Quoted string
Text string
}

TemplateNode struct #

TemplateNode represents a {{template}} action.

type TemplateNode struct {
NodeType
Pos
tr *Tree
Line int
Name string
Pipe *PipeNode
}

TextNode struct #

TextNode holds plain text.

type TextNode struct {
NodeType
Pos
tr *Tree
Text []byte
}

Tree struct #

Tree is the representation of a single parsed template.

type Tree struct {
Name string
ParseName string
Root *ListNode
Mode Mode
text string
funcs []map[string]any
lex *lexer
token [3]item
peekCount int
vars []string
treeSet map[string]*Tree
actionLine int
rangeDepth int
}

VariableNode struct #

VariableNode holds a list of variable names, possibly with chained field accesses. The dollar sign is part of the (first) name.

type VariableNode struct {
NodeType
Pos
tr *Tree
Ident []string
}

WithNode struct #

WithNode represents a {{with}} action and its commands.

type WithNode struct {
BranchNode
}

elseNode struct #

elseNode represents an {{else}} action. Does not appear in the final tree.

type elseNode struct {
NodeType
Pos
tr *Tree
Line int
}

endNode struct #

endNode represents an {{end}} action. It does not appear in the final parse tree.

type endNode struct {
NodeType
Pos
tr *Tree
}

item struct #

item represents a token or text string returned from the scanner.

type item struct {
typ itemType
pos Pos
val string
line int
}

lexOptions struct #

lexOptions control behavior of the lexer. All default to false.

type lexOptions struct {
emitComment bool
breakOK bool
continueOK bool
}

lexer struct #

lexer holds the state of the scanner.

type lexer struct {
name string
input string
leftDelim string
rightDelim string
pos Pos
start Pos
atEOF bool
parenDepth int
line int
startLine int
item item
insideAction bool
options lexOptions
}

Functions

Add method #

Add adds the named field (which should start with a period) to the end of the chain.

func (c *ChainNode) Add(field string)

Copy method #

func (w *WithNode) Copy() Node

Copy method #

Copy returns a copy of the [Tree]. Any parsing state is discarded.

func (t *Tree) Copy() *Tree

Copy method #

func (v *VariableNode) Copy() Node

Copy method #

func (n *NilNode) Copy() Node

Copy method #

func (f *FieldNode) Copy() Node

Copy method #

func (i *IdentifierNode) Copy() Node

Copy method #

func (b *BreakNode) Copy() Node

Copy method #

func (c *ChainNode) Copy() Node

Copy method #

func (c *CommandNode) Copy() Node

Copy method #

func (b *BoolNode) Copy() Node

Copy method #

func (a *ActionNode) Copy() Node

Copy method #

func (n *NumberNode) Copy() Node

Copy method #

func (s *StringNode) Copy() Node

Copy method #

func (p *PipeNode) Copy() Node

Copy method #

func (e *endNode) Copy() Node

Copy method #

func (c *CommentNode) Copy() Node

Copy method #

func (e *elseNode) Copy() Node

Copy method #

func (t *TextNode) Copy() Node

Copy method #

func (b *BranchNode) Copy() Node

Copy method #

func (i *IfNode) Copy() Node

Copy method #

func (l *ListNode) Copy() Node

Copy method #

func (d *DotNode) Copy() Node

Copy method #

func (c *ContinueNode) Copy() Node

Copy method #

func (r *RangeNode) Copy() Node

Copy method #

func (t *TemplateNode) Copy() Node

CopyList method #

func (l *ListNode) CopyList() *ListNode

CopyPipe method #

func (p *PipeNode) CopyPipe() *PipeNode

ErrorContext method #

ErrorContext returns a textual representation of the location of the node in the input text. The receiver is only used when the node does not have a pointer to the tree inside, which can occur in old code.

func (t *Tree) ErrorContext(n Node) (location string, context string)

IsEmptyTree function #

IsEmptyTree reports whether this tree (node) is empty of everything but space or comments.

func IsEmptyTree(n Node) bool

New function #

New allocates a new parse tree with the given name.

func New(name string, funcs ...map[string]any) *Tree

NewIdentifier function #

NewIdentifier returns a new [IdentifierNode] with the given identifier name.

func NewIdentifier(ident string) *IdentifierNode

Parse method #

Parse parses the template definition string to construct a representation of the template for execution. If either action delimiter string is empty, the default ("{{" or "}}") is used. Embedded template definitions are added to the treeSet map.

func (t *Tree) Parse(text string, leftDelim string, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]any) (tree *Tree, err error)

Parse function #

Parse returns a map from template name to [Tree], created by parsing the templates described in the argument string. The top-level template will be given the specified name. If an error is encountered, parsing stops and an empty map is returned with the error.

func Parse(name string, text string, leftDelim string, rightDelim string, funcs ...map[string]any) (map[string]*Tree, error)

Position method #

func (p Pos) Position() Pos

SetPos method #

SetPos sets the position. [NewIdentifier] is a public method so we can't modify its signature. Chained for convenience. TODO: fix one day?

func (i *IdentifierNode) SetPos(pos Pos) *IdentifierNode

SetTree method #

SetTree sets the parent tree for the node. [NewIdentifier] is a public method so we can't modify its signature. Chained for convenience. TODO: fix one day?

func (i *IdentifierNode) SetTree(t *Tree) *IdentifierNode

String method #

func (b *BoolNode) String() string

String method #

func (e *endNode) String() string

String method #

func (f *FieldNode) String() string

String method #

func (c *ContinueNode) String() string

String method #

func (l *ListNode) String() string

String method #

func (s *StringNode) String() string

String method #

func (c *ChainNode) String() string

String method #

func (a *ActionNode) String() string

String method #

func (b *BreakNode) String() string

String method #

func (t *TextNode) String() string

String method #

func (i *IdentifierNode) String() string

String method #

func (i item) String() string

String method #

func (d *DotNode) String() string

String method #

func (b *BranchNode) String() string

String method #

func (c *CommentNode) String() string

String method #

func (n *NumberNode) String() string

String method #

func (e *elseNode) String() string

String method #

func (n *NilNode) String() string

String method #

func (t *TemplateNode) String() string

String method #

func (v *VariableNode) String() string

String method #

func (p *PipeNode) String() string

String method #

func (c *CommandNode) String() string

Type method #

func (e *elseNode) Type() NodeType

Type method #

func (d *DotNode) Type() NodeType

Type method #

Type returns itself and provides an easy default implementation for embedding in a Node. Embedded in all non-trivial Nodes.

func (t NodeType) Type() NodeType

Type method #

func (n *NilNode) Type() NodeType

accept method #

accept consumes the next rune if it's from the valid set.

func (l *lexer) accept(valid string) bool

acceptRun method #

acceptRun consumes a run of runes from the valid set.

func (l *lexer) acceptRun(valid string)

action method #

Action: control command ("|" command)* Left delim is past. Now get actions. First word could be a keyword such as range.

func (t *Tree) action() (n Node)

add method #

add adds tree to t.treeSet.

func (t *Tree) add()

append method #

func (c *CommandNode) append(arg Node)

append method #

func (p *PipeNode) append(command *CommandNode)

append method #

func (l *ListNode) append(n Node)

atRightDelim method #

atRightDelim reports whether the lexer is at a right delimiter, possibly preceded by a trim marker.

func (l *lexer) atRightDelim() (delim bool, trimSpaces bool)

atTerminator method #

atTerminator reports whether the input is at valid termination character to appear after an identifier. Breaks .X.Y into two pieces. Also catches cases like "$x+2" not being acceptable without a space, in case we decide one day to implement arithmetic.

func (l *lexer) atTerminator() bool

backup method #

backup steps back one rune.

func (l *lexer) backup()

backup method #

backup backs the input stream up one token.

func (t *Tree) backup()

backup2 method #

backup2 backs the input stream up two tokens. The zeroth token is already there.

func (t *Tree) backup2(t1 item)

backup3 method #

backup3 backs the input stream up three tokens The zeroth token is already there.

func (t *Tree) backup3(t2 item, t1 item)

blockControl method #

Block: {{block stringValue pipeline}} Block keyword is past. The name must be something that can evaluate to a string. The pipeline is mandatory.

func (t *Tree) blockControl() Node

breakControl method #

Break: {{break}} Break keyword is past.

func (t *Tree) breakControl(pos Pos, line int) Node

checkPipeline method #

func (t *Tree) checkPipeline(pipe *PipeNode, context string)

clearActionLine method #

func (t *Tree) clearActionLine()

command method #

command: operand (space operand)* space-separated arguments up to a pipeline character or right delimiter. we consume the pipe character but leave the right delim to terminate the action.

func (t *Tree) command() *CommandNode

continueControl method #

Continue: {{continue}} Continue keyword is past.

func (t *Tree) continueControl(pos Pos, line int) Node

elseControl method #

Else: {{else}} Else keyword is past.

func (t *Tree) elseControl() Node

emit method #

emit passes the trailing text as an item back to the parser.

func (l *lexer) emit(t itemType) stateFn

emitItem method #

emitItem passes the specified item to the parser.

func (l *lexer) emitItem(i item) stateFn

endControl method #

End: {{end}} End keyword is past.

func (t *Tree) endControl() Node

error method #

error terminates processing.

func (t *Tree) error(err error)

errorf method #

errorf returns an error token and terminates the scan by passing back a nil pointer that will be the next state, terminating l.nextItem.

func (l *lexer) errorf(format string, args ...any) stateFn

errorf method #

errorf formats the error and terminates processing.

func (t *Tree) errorf(format string, args ...any)

expect method #

expect consumes the next token and guarantees it has the required type.

func (t *Tree) expect(expected itemType, context string) item

expectOneOf method #

expectOneOf consumes the next token and guarantees it has one of the required types.

func (t *Tree) expectOneOf(expected1 itemType, expected2 itemType, context string) item

hasFunction method #

hasFunction reports if a function name exists in the Tree's maps.

func (t *Tree) hasFunction(name string) bool

hasLeftTrimMarker function #

func hasLeftTrimMarker(s string) bool

hasRightTrimMarker function #

func hasRightTrimMarker(s string) bool

ifControl method #

If: {{if pipeline}} itemList {{end}} {{if pipeline}} itemList {{else}} itemList {{end}} If keyword is past.

func (t *Tree) ifControl() Node

ignore method #

ignore skips over the pending input before this point. It tracks newlines in the ignored text, so use it only for text that is skipped without calling l.next.

func (l *lexer) ignore()

isAlphaNumeric function #

isAlphaNumeric reports whether r is an alphabetic, digit, or underscore.

func isAlphaNumeric(r rune) bool

isSpace function #

isSpace reports whether r is a space character.

func isSpace(r rune) bool

itemList method #

itemList: textOrAction* Terminates at {{end}} or {{else}}, returned separately.

func (t *Tree) itemList() (list *ListNode, next Node)

leftTrimLength function #

leftTrimLength returns the length of the spaces at the beginning of the string.

func leftTrimLength(s string) Pos

lex function #

lex creates a new scanner for the input string.

func lex(name string, input string, left string, right string) *lexer

lexChar function #

lexChar scans a character constant. The initial quote is already scanned. Syntax checking is done by the parser.

func lexChar(l *lexer) stateFn

lexComment function #

lexComment scans a comment. The left comment marker is known to be present.

func lexComment(l *lexer) stateFn

lexField function #

lexField scans a field: .Alphanumeric. The . has been scanned.

func lexField(l *lexer) stateFn

lexFieldOrVariable function #

lexFieldOrVariable scans a field or variable: [.$]Alphanumeric. The . or $ has been scanned.

func lexFieldOrVariable(l *lexer, typ itemType) stateFn

lexIdentifier function #

lexIdentifier scans an alphanumeric.

func lexIdentifier(l *lexer) stateFn

lexInsideAction function #

lexInsideAction scans the elements inside action delimiters.

func lexInsideAction(l *lexer) stateFn

lexLeftDelim function #

lexLeftDelim scans the left delimiter, which is known to be present, possibly with a trim marker. (The text to be trimmed has already been emitted.)

func lexLeftDelim(l *lexer) stateFn

lexNumber function #

lexNumber scans a number: decimal, octal, hex, float, or imaginary. This isn't a perfect number scanner - for instance it accepts "." and "0x0.2" and "089" - but when it's wrong the input is invalid and the parser (via strconv) will notice.

func lexNumber(l *lexer) stateFn

lexQuote function #

lexQuote scans a quoted string.

func lexQuote(l *lexer) stateFn

lexRawQuote function #

lexRawQuote scans a raw quoted string.

func lexRawQuote(l *lexer) stateFn

lexRightDelim function #

lexRightDelim scans the right delimiter, which is known to be present, possibly with a trim marker.

func lexRightDelim(l *lexer) stateFn

lexSpace function #

lexSpace scans a run of space characters. We have not consumed the first space, which is known to be present. Take care if there is a trim-marked right delimiter, which starts with a space.

func lexSpace(l *lexer) stateFn

lexText function #

lexText scans until an opening action delimiter, "{{".

func lexText(l *lexer) stateFn

lexVariable function #

lexVariable scans a Variable: $Alphanumeric. The $ has been scanned.

func lexVariable(l *lexer) stateFn

newAction method #

func (t *Tree) newAction(pos Pos, line int, pipe *PipeNode) *ActionNode

newBool method #

func (t *Tree) newBool(pos Pos, true bool) *BoolNode

newBreak method #

func (t *Tree) newBreak(pos Pos, line int) *BreakNode

newChain method #

func (t *Tree) newChain(pos Pos, node Node) *ChainNode

newCommand method #

func (t *Tree) newCommand(pos Pos) *CommandNode

newComment method #

func (t *Tree) newComment(pos Pos, text string) *CommentNode

newContinue method #

func (t *Tree) newContinue(pos Pos, line int) *ContinueNode

newDot method #

func (t *Tree) newDot(pos Pos) *DotNode

newElse method #

func (t *Tree) newElse(pos Pos, line int) *elseNode

newEnd method #

func (t *Tree) newEnd(pos Pos) *endNode

newField method #

func (t *Tree) newField(pos Pos, ident string) *FieldNode

newIf method #

func (t *Tree) newIf(pos Pos, line int, pipe *PipeNode, list *ListNode, elseList *ListNode) *IfNode

newList method #

func (t *Tree) newList(pos Pos) *ListNode

newNil method #

func (t *Tree) newNil(pos Pos) *NilNode

newNumber method #

func (t *Tree) newNumber(pos Pos, text string, typ itemType) (*NumberNode, error)

newPipeline method #

func (t *Tree) newPipeline(pos Pos, line int, vars []*VariableNode) *PipeNode

newRange method #

func (t *Tree) newRange(pos Pos, line int, pipe *PipeNode, list *ListNode, elseList *ListNode) *RangeNode

newString method #

func (t *Tree) newString(pos Pos, orig string, text string) *StringNode

newTemplate method #

func (t *Tree) newTemplate(pos Pos, line int, name string, pipe *PipeNode) *TemplateNode

newText method #

func (t *Tree) newText(pos Pos, text string) *TextNode

newVariable method #

func (t *Tree) newVariable(pos Pos, ident string) *VariableNode

newWith method #

func (t *Tree) newWith(pos Pos, line int, pipe *PipeNode, list *ListNode, elseList *ListNode) *WithNode

next method #

next returns the next token.

func (t *Tree) next() item

next method #

next returns the next rune in the input.

func (l *lexer) next() rune

nextItem method #

nextItem returns the next item from the input. Called by the parser, not in the lexing goroutine.

func (l *lexer) nextItem() item

nextNonSpace method #

nextNonSpace returns the next non-space token.

func (t *Tree) nextNonSpace() (token item)

operand method #

operand: term .Field* An operand is a space-separated component of a command, a term possibly followed by field accesses. A nil return means the next item is not an operand.

func (t *Tree) operand() Node

parse method #

parse is the top-level parser for a template, essentially the same as itemList except it also parses {{define}} actions. It runs to EOF.

func (t *Tree) parse()

parseControl method #

func (t *Tree) parseControl(context string) (pos Pos, line int, pipe *PipeNode, list *ListNode, elseList *ListNode)

parseDefinition method #

parseDefinition parses a {{define}} ... {{end}} template definition and installs the definition in t.treeSet. The "define" keyword has already been scanned.

func (t *Tree) parseDefinition()

parseTemplateName method #

func (t *Tree) parseTemplateName(token item, context string) (name string)

peek method #

peek returns but does not consume the next rune in the input.

func (l *lexer) peek() rune

peek method #

peek returns but does not consume the next token.

func (t *Tree) peek() item

peekNonSpace method #

peekNonSpace returns but does not consume the next non-space token.

func (t *Tree) peekNonSpace() item

pipeline method #

Pipeline: declarations? command ('|' command)*

func (t *Tree) pipeline(context string, end itemType) (pipe *PipeNode)

popVars method #

popVars trims the variable list to the specified length

func (t *Tree) popVars(n int)

rangeControl method #

Range: {{range pipeline}} itemList {{end}} {{range pipeline}} itemList {{else}} itemList {{end}} Range keyword is past.

func (t *Tree) rangeControl() Node

recover method #

recover is the handler that turns panics into returns from the top level of Parse.

func (t *Tree) recover(errp *error)

rightTrimLength function #

rightTrimLength returns the length of the spaces at the end of the string.

func rightTrimLength(s string) Pos

scanNumber method #

func (l *lexer) scanNumber() bool

simplifyComplex method #

simplifyComplex pulls out any other types that are represented by the complex number. These all require that the imaginary part be zero.

func (n *NumberNode) simplifyComplex()

startParse method #

startParse initializes the parser, using the lexer.

func (t *Tree) startParse(funcs []map[string]any, lex *lexer, treeSet map[string]*Tree)

stopParse method #

stopParse terminates parsing.

func (t *Tree) stopParse()

templateControl method #

Template: {{template stringValue pipeline}} Template keyword is past. The name must be something that can evaluate to a string.

func (t *Tree) templateControl() Node

term method #

term: literal (number, string, nil, boolean) function (identifier) . .Field $ '(' pipeline ')' A term is a simple "expression". A nil return means the next item is not a term.

func (t *Tree) term() Node

textOrAction method #

textOrAction: text | comment | action

func (t *Tree) textOrAction() Node

thisItem method #

thisItem returns the item at the current input point with the specified type and advances the input.

func (l *lexer) thisItem(t itemType) item

tree method #

func (a *ActionNode) tree() *Tree

tree method #

func (s *StringNode) tree() *Tree

tree method #

func (n *NilNode) tree() *Tree

tree method #

func (v *VariableNode) tree() *Tree

tree method #

func (c *ContinueNode) tree() *Tree

tree method #

func (l *ListNode) tree() *Tree

tree method #

func (f *FieldNode) tree() *Tree

tree method #

func (i *IdentifierNode) tree() *Tree

tree method #

func (b *BreakNode) tree() *Tree

tree method #

func (c *ChainNode) tree() *Tree

tree method #

func (c *CommandNode) tree() *Tree

tree method #

func (t *TextNode) tree() *Tree

tree method #

func (b *BranchNode) tree() *Tree

tree method #

func (b *BoolNode) tree() *Tree

tree method #

func (n *NumberNode) tree() *Tree

tree method #

func (d *DotNode) tree() *Tree

tree method #

func (e *elseNode) tree() *Tree

tree method #

func (t *TemplateNode) tree() *Tree

tree method #

func (c *CommentNode) tree() *Tree

tree method #

func (p *PipeNode) tree() *Tree

tree method #

func (e *endNode) tree() *Tree

unexpected method #

unexpected complains about the token and terminates processing.

func (t *Tree) unexpected(token item, context string)

useVar method #

useVar returns a node for a variable reference. It errors if the variable is not defined.

func (t *Tree) useVar(pos Pos, name string) Node

withControl method #

With: {{with pipeline}} itemList {{end}} {{with pipeline}} itemList {{else}} itemList {{end}} If keyword is past.

func (t *Tree) withControl() Node

writeTo method #

func (b *BranchNode) writeTo(sb *strings.Builder)

writeTo method #

func (c *ChainNode) writeTo(sb *strings.Builder)

writeTo method #

func (c *CommentNode) writeTo(sb *strings.Builder)

writeTo method #

func (e *endNode) writeTo(sb *strings.Builder)

writeTo method #

func (n *NumberNode) writeTo(sb *strings.Builder)

writeTo method #

func (c *CommandNode) writeTo(sb *strings.Builder)

writeTo method #

func (s *StringNode) writeTo(sb *strings.Builder)

writeTo method #

func (b *BoolNode) writeTo(sb *strings.Builder)

writeTo method #

func (t *TextNode) writeTo(sb *strings.Builder)

writeTo method #

func (e *elseNode) writeTo(sb *strings.Builder)

writeTo method #

func (i *IdentifierNode) writeTo(sb *strings.Builder)

writeTo method #

func (a *ActionNode) writeTo(sb *strings.Builder)

writeTo method #

func (b *BreakNode) writeTo(sb *strings.Builder)

writeTo method #

func (l *ListNode) writeTo(sb *strings.Builder)

writeTo method #

func (f *FieldNode) writeTo(sb *strings.Builder)

writeTo method #

func (v *VariableNode) writeTo(sb *strings.Builder)

writeTo method #

func (c *ContinueNode) writeTo(sb *strings.Builder)

writeTo method #

func (t *TemplateNode) writeTo(sb *strings.Builder)

writeTo method #

func (n *NilNode) writeTo(sb *strings.Builder)

writeTo method #

func (d *DotNode) writeTo(sb *strings.Builder)

writeTo method #

func (p *PipeNode) writeTo(sb *strings.Builder)

Generated with Arrow