Index | Files

package parse

import ""

Package parse builds parse trees for configurations as defined by conf. Clients should use that package to construct configurations rather than this one, which provides shared internal data structures not intended for general use.


Package Files

lex.go node.go parse.go

type ListNode Uses

type ListNode struct {
    Nodes []Node // The element nodes in lexical order.

ListNode holds a sequence of nodes.

func (*ListNode) String Uses

func (l *ListNode) String() string

type Node Uses

type Node interface {
    Type() NodeType
    String() string
    Position() Pos // byte position of start of node in full original input string
    // contains filtered or unexported methods

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 NodeType Uses

type NodeType int

NodeType identifies the type of a parse tree node.

const (
    NodePair    NodeType = iota // key=value expression.
    NodeList                    // A list of nodes.
    NodeString                  // A string constant.
    NodeSection                 // [section] definition.

func (NodeType) Type Uses

func (t NodeType) Type() NodeType

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

type PairNode Uses

type PairNode struct {
    Key, Val *StringNode

PairNode holds a key=value pair.

func (*PairNode) String Uses

func (p *PairNode) String() string

type Pos Uses

type Pos int

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

func (Pos) Position Uses

func (p Pos) Position() Pos

type SectionNode Uses

type SectionNode struct {
    RawText     string
    SectionType *StringNode
    Name        *StringNode
    Nodes       *ListNode

SectionNode holds a section name and children

func (*SectionNode) String Uses

func (s *SectionNode) String() string

type StringNode Uses

type StringNode struct {
    Quoted string // The original text of the string, with possible quotes.
    Text   string // The string, after quote processing.

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

func (*StringNode) String Uses

func (s *StringNode) String() string

type Tree Uses

type Tree struct {
    Name string    // name of the template represented by the tree.
    Root *ListNode // top-level root of the tree.
    // contains filtered or unexported fields

Tree is the representation of a single parsed configuration.

func New Uses

func New(name string) *Tree

New allocates a new parse tree with the given name.

func Parse Uses

func Parse(name, text string) (t *Tree, err error)

Parse returns a Tree, created by parsing the configuration described in the argument string. If an error is encountered, parsing stops and an empty Tree is returned with the error.

func (*Tree) ErrorContext Uses

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

ErrorContext returns a textual representation of the location of the node in the input text.

func (*Tree) Parse Uses

func (t *Tree) Parse(text string) (err error)

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.

Package parse imports 7 packages (graph) and is imported by 1 packages. Updated 2016-07-28. Refresh now. Tools for package owners.