Documentation ¶
Overview ¶
Package sparse implements a sparse definition parser.
Sparse is effectively an attribute language parser, where the language resembles Quake 3 style shaders. For example:
textures/base/wall_arc_01 { { # unit map textures/base/wall_arc_01.tga } { map textures/base/wall_arc_01.glow.tga blend add } next-line-brace { } no-collision! depth lte alpha always grid 1 1 1 \ 1 1 1 \ 1 1 1 }
Which would yield the following Pieces (either via a Parser or calling Parse):
NodeEnter("textures/base/wall_arc_01") NodeEnter("") // Unnamed nodes are given the empty key Comment(" unit") // If ReadComments(true) Field{"map", "textures/base/wall_arc_01.tga"} NodeLeave(2) // The integer value corresponds to node depth NodeEnter() Field{"map", "textures/base/wall_arc_01.glow.tga"} Field{"blend", "add"} NodeLeave(2) NodeEnter("next-line-brace") // Names go until they encounter a value, brace, or semicolon. NodeLeave(2) Field{"no-collision", ""} Field{"depth", "lte"} Field{"alpha", "always"} Field{"grid", "1 1 1\n1 1 1\n1 1 1" NodeLeave(1)
Index ¶
Constants ¶
View Source
const ( KindField pieceKind = 1 + iota KindComment KindNodeEnter KindNodeLeave )
Variables ¶
View Source
var ErrUnexpectedNodeLeave = errors.New("sparse: unexpected end of node")
Functions ¶
This section is empty.
Types ¶
type ASCIIReader ¶
func (ASCIIReader) ReadByte ¶
func (r ASCIIReader) ReadByte() (byte, error)
type CompressWhitespace ¶
type CompressWhitespace bool
type Configuration ¶
type Configuration interface {
// contains filtered or unexported methods
}
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewParser ¶
func NewParser(configs ...Configuration) *Parser
func (*Parser) Reset ¶
func (p *Parser) Reset(configs ...Configuration)
type ReadComments ¶
type ReadComments bool
type TrimWhitespace ¶
type TrimWhitespace bool
Click to show internal directories.
Click to hide internal directories.