Documentation ¶
Index ¶
- Constants
- Variables
- type AST
- type Builder
- func (b *Builder) Backup(ctx *builderCtx)
- func (b *Builder) Backup2(ctx *builderCtx, t1 lex.LexItem)
- func (b *Builder) DeclareLocalVarIfNew(ctx *builderCtx, symbol lex.LexItem)
- func (b *Builder) LocalVarOrFetchSymbol(ctx *builderCtx, token lex.LexItem) node.Node
- func (b *Builder) Next(ctx *builderCtx) lex.LexItem
- func (b *Builder) NextNonSpace(ctx *builderCtx) lex.LexItem
- func (b *Builder) Parse(name string, l lex.Lexer) (ast *AST, err error)
- func (b *Builder) ParseArrayElementFetch(ctx *builderCtx, invocant node.Node) node.Node
- func (b *Builder) ParseAssignment(ctx *builderCtx) node.Node
- func (b *Builder) ParseElse(ctx *builderCtx) node.Node
- func (b *Builder) ParseExpression(ctx *builderCtx, canPrint bool) (n node.Node)
- func (b *Builder) ParseExpressionOrAssignment(ctx *builderCtx, canPrint bool) node.Node
- func (b *Builder) ParseFilter(ctx *builderCtx, n node.Node) node.Node
- func (b *Builder) ParseForeach(ctx *builderCtx) node.Node
- func (b *Builder) ParseFunCall(ctx *builderCtx, invocant node.Node) node.Node
- func (b *Builder) ParseGroup(ctx *builderCtx) node.Node
- func (b *Builder) ParseIf(ctx *builderCtx) node.Node
- func (b *Builder) ParseInclude(ctx *builderCtx) node.Node
- func (b *Builder) ParseList(ctx *builderCtx) node.Node
- func (b *Builder) ParseListVariableOrMakeArray(ctx *builderCtx) node.Node
- func (b *Builder) ParseLiteral(ctx *builderCtx) node.Node
- func (b *Builder) ParseMacro(ctx *builderCtx) node.Node
- func (b *Builder) ParseMakeArray(ctx *builderCtx) node.Node
- func (b *Builder) ParseMethodCallOrMapLookup(ctx *builderCtx, invocant node.Node) node.Node
- func (b *Builder) ParseRange(ctx *builderCtx) node.Node
- func (b *Builder) ParseRawString(ctx *builderCtx) node.Node
- func (b *Builder) ParseStatements(ctx *builderCtx) node.Node
- func (b *Builder) ParseTemplate(ctx *builderCtx) node.Node
- func (b *Builder) ParseTemplateOrText(ctx *builderCtx) node.Node
- func (b *Builder) ParseTerm(ctx *builderCtx) node.Node
- func (b *Builder) ParseWhile(ctx *builderCtx) node.Node
- func (b *Builder) ParseWrapper(ctx *builderCtx) node.Node
- func (b *Builder) Peek(ctx *builderCtx) lex.LexItem
- func (b *Builder) PeekNonSpace(ctx *builderCtx) lex.LexItem
- func (b *Builder) Start(ctx *builderCtx)
- func (b *Builder) Unexpected(ctx *builderCtx, format string, args ...interface{})
- type Frame
- type LexSymbol
- type LexSymbolList
- type LexSymbolSet
- type LexSymbolSorter
- type Lexer
- type Parser
Constants ¶
const ( ItemError lex.ItemType = lex.ItemDefaultMax + 1 + iota ItemEOF ItemRawString ItemComment ItemNumber ItemComplex ItemChar ItemSpace ItemTagStart ItemTagEnd ItemSymbol ItemIdentifier ItemDoubleQuotedString ItemSingleQuotedString ItemBool ItemField ItemComma ItemOpenParen // '(' ItemCloseParen // ')' ItemOpenSquareBracket // '[' ItemCloseSquareBracket // ']' ItemPeriod // '.' ItemKeyword // Delimiter ItemCall // CALL ItemGet // GET ItemSet // SET ItemMacro // MACRO ItemBlock // BLOCK ItemForeach // FOREACH ItemWhile // WHILE ItemIn // IN ItemInclude // INCLUDE ItemWith // WITH ItemIf // IF ItemElse // ELSE ItemElseIf // ELSIF ItemUnless // UNLESS ItemSwitch // SWITCH ItemCase // CASE ItemWrapper // WRAPPER ItemDefault // DEFAULT ItemEnd // END ItemOperator // Delimiter ItemRange // .. ItemEquals // == ItemNotEquals // != ItemGT // > ItemLT // < ItemCmp // <=> ItemLE // <= ItemGE // >= ItemShiftLeft // << ItemShiftRight // >> ItemAssignAdd // += ItemAssignSub // -= ItemAssignMul // *= ItemAssignDiv // /= ItemAssignMod // %= ItemAnd // && ItemOr // || ItemFatComma // => ItemIncr // ++ ItemDecr // -- ItemPlus ItemMinus ItemAsterisk ItemSlash ItemVerticalSlash ItemMod ItemAssign // = DefaultItemTypeMax )
Variables ¶
var DefaultSymbolSet = NewLexSymbolSet()
DefaultSymbolSet is the LexSymbolSet for symbols that are common to all syntax
Functions ¶
This section is empty.
Types ¶
type AST ¶
type AST struct { Name string // name of the template ParseName string // name of the top-level template during parsing Root *node.ListNode // root of the tree Timestamp time.Time // last-modified date of this template // contains filtered or unexported fields }
AST is represents the syntax tree for an Xslate template
type Builder ¶
type Builder struct { }
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) DeclareLocalVarIfNew ¶
func (b *Builder) DeclareLocalVarIfNew(ctx *builderCtx, symbol lex.LexItem)
func (*Builder) LocalVarOrFetchSymbol ¶
func (*Builder) NextNonSpace ¶
func (b *Builder) NextNonSpace(ctx *builderCtx) lex.LexItem
func (*Builder) ParseArrayElementFetch ¶
func (*Builder) ParseAssignment ¶
func (*Builder) ParseExpression ¶
func (*Builder) ParseExpressionOrAssignment ¶
func (*Builder) ParseForeach ¶
func (*Builder) ParseFunCall ¶
func (*Builder) ParseGroup ¶
func (*Builder) ParseInclude ¶
func (*Builder) ParseListVariableOrMakeArray ¶
func (*Builder) ParseLiteral ¶
func (*Builder) ParseMacro ¶
func (*Builder) ParseMakeArray ¶
func (*Builder) ParseMethodCallOrMapLookup ¶
func (*Builder) ParseRange ¶
func (*Builder) ParseRawString ¶
func (*Builder) ParseStatements ¶
func (*Builder) ParseTemplate ¶
func (*Builder) ParseTemplateOrText ¶
func (*Builder) ParseWhile ¶
func (*Builder) ParseWrapper ¶
func (*Builder) PeekNonSpace ¶
func (b *Builder) PeekNonSpace(ctx *builderCtx) lex.LexItem
func (*Builder) Unexpected ¶
type Frame ¶
type Frame struct { *frame.Frame Node node.Appender // This contains names of local variables, mapped to their // respective location in the framestack LvarNames map[string]int }
Frame is the frame struct used during parsing, which has a bit of extension over the common Frame struct.
type LexSymbolList ¶
type LexSymbolList []LexSymbol
LexSymbolList a list of LexSymbols. Normally you do not need to use it. This is mainly only useful for sorting LexSymbols
func (LexSymbolList) Sort ¶
func (list LexSymbolList) Sort() LexSymbolList
Sort returns a sorted list of LexSymbols, sorted by Priority
type LexSymbolSet ¶
type LexSymbolSet struct { Map map[string]LexSymbol SortedList LexSymbolList }
LexSymbolSet is the container for symbols.
func NewLexSymbolSet ¶
func NewLexSymbolSet() *LexSymbolSet
NewLexSymbolSet creates a new LexSymbolSet
func (*LexSymbolSet) Copy ¶
func (l *LexSymbolSet) Copy() *LexSymbolSet
Copy creates a new copy of the given LexSymbolSet
func (*LexSymbolSet) Count ¶
func (l *LexSymbolSet) Count() int
Count returns the number of symbols registered
func (*LexSymbolSet) Get ¶
func (l *LexSymbolSet) Get(name string) LexSymbol
Get returns the LexSymbol associated with `name`
func (*LexSymbolSet) GetSortedList ¶
func (l *LexSymbolSet) GetSortedList() LexSymbolList
GetSortedList returns the lsit of LexSymbols in order that they should be searched for in the tempalte
func (*LexSymbolSet) Set ¶
func (l *LexSymbolSet) Set(name string, typ lex.ItemType, prio ...float32)
Set creates and sets a new LexItem to `name`
type LexSymbolSorter ¶
type LexSymbolSorter struct {
// contains filtered or unexported fields
}
LexSymbolSorter sorts a list of LexSymbols by priority
func (LexSymbolSorter) Less ¶
func (s LexSymbolSorter) Less(i, j int) bool
Less returns true if the i-th element's Priority is less than the j-th element
func (LexSymbolSorter) Swap ¶
func (s LexSymbolSorter) Swap(i, j int)
Swap swaps the elements at i and j
type Lexer ¶
type Lexer struct { lex.Lexer // contains filtered or unexported fields }
func NewReaderLexer ¶
func NewReaderLexer(rdr io.Reader, ss *LexSymbolSet) *Lexer
func NewStringLexer ¶
func NewStringLexer(template string, ss *LexSymbolSet) *Lexer