parser

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(tokens <-chan lexer.Token) *Parser

type StateFn

type StateFn func() StateFn

StateFn represents the state of the parser as a function that returns the next state.

type Tree

type Tree struct {
	Values   map[string]interface{} // string -> *Value, *Tree, []*Tree, comments
	Position lexer.Position
}

Tree is the result of the parsing of a SAN file.

func NewTree

func NewTree() *Tree

NewTree initialize a new Tree

func Parse

func Parse(input []byte) (*Tree, error)

func ParseTokens

func ParseTokens(tokens <-chan lexer.Token) (*Tree, error)

func (*Tree) Get

func (t *Tree) Get(key string) interface{}

Get the value at key in the Tree. Key is a dot-separated path (e.g. a.b.c) without single/double quoted strings. If you need to retrieve non-bare keys, use GetPath. Returns nil if the path does not exist in the tree. If keys is of length zero, the current tree is returned.

func (*Tree) GetPath

func (t *Tree) GetPath(keys []string) interface{}

GetPath returns the element in the tree indicated by 'keys'. If keys is of length zero, the current tree is returned.

func (*Tree) Has

func (t *Tree) Has(key string) bool

Has returns a boolean indicating if the given key exists.

func (*Tree) HasPath

func (t *Tree) HasPath(keys []string) bool

HasPath returns true if the given path of keys exists, false otherwise.

func (*Tree) Keys

func (t *Tree) Keys() []string

Keys returns the keys of the toplevel tree (does not recurse).

func (*Tree) Set

func (t *Tree) Set(key string, value interface{})

Set an element in the tree. Key is a dot-separated path (e.g. a.b.c). Creates all necessary intermediate trees, if needed.

func (*Tree) SetPath

func (t *Tree) SetPath(keys []string, value interface{})

func (*Tree) SetPathWithOptions

func (t *Tree) SetPathWithOptions(keys []string, value interface{}, multiline bool)

SetPathWithOptions is the same as SetPath, but allows you to provide formatting instructions to the key, that will be reused by Marshal().

func (*Tree) SetWithOptions

func (t *Tree) SetWithOptions(key string, value interface{}, multiline bool)

SetWithOptions is the same as Set, but allows you to provide formatting instructions to the key, that will be used by Marshal().

func (*Tree) Write

func (t *Tree) Write(w io.Writer, indent, keyspace string, bytesCount int64, arraysOneElementPerLine bool) (int64, error)

Write write a value to w

type Value

type Value struct {
	Val      interface{} // string, int64, uint64, float64, bool or [] of any
	Position lexer.Position
}

Value represents a SAN value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL