gem

package
v0.0.0-...-1d585eb Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package gem provides a GEneral Model for XSX data

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(pr xsx.Printer, xpr Expr) (err error)
Example
pr := xsx.Compact(os.Stdout)
gem := Sequence{Elems: []Expr{
	&Atom{Str: "foo"},
	&Sequence{Elems: []Expr{&Atom{Str: "bar"}}},
	&Atom{Str: "baz"},
}}
gem.SetBrace(Square)
gem.Elems[0].(*Atom).SetQuoted(true)
gem.Elems[1].SetMeta(true)
Print(pr, &gem)
Output:

["foo"\(bar)baz]
Example (Atom)
pr := xsx.Compact(os.Stdout)
gem := Atom{Str: "foo"}
Print(pr, &gem)
Output:

foo
Example (Eseq)
pr := xsx.Compact(os.Stdout)
gem := Sequence{}
gem.SetBrace(Square)
Print(pr, &gem)
Output:

[]
Example (Qatom)
pr := xsx.Compact(os.Stdout)
gem := Atom{Str: "foo bar"}
Print(pr, &gem)
Output:

"foo bar"

Types

type Atom

type Atom struct {
	Str string
	// contains filtered or unexported fields
}

func (Atom) Meta

func (e Atom) Meta() bool

func (*Atom) Quoted

func (a *Atom) Quoted() bool

func (*Atom) SetMeta

func (e *Atom) SetMeta(flag bool)

func (*Atom) SetQuoted

func (a *Atom) SetQuoted(flag bool)

type Brace

type Brace int
const (
	Undef  Brace = 0
	Paren  Brace = 1 << 0
	Square Brace = 1 << 1
	Curly  Brace = 1 << 2
)

func FromRune

func FromRune(c byte) Brace

func (Brace) Closing

func (b Brace) Closing() (res rune)

func (Brace) Opening

func (b Brace) Opening() (res rune)

func (Brace) String

func (i Brace) String() string

type Expr

type Expr interface {
	Meta() bool
	SetMeta(flag bool)
}

func ReadCurrent

func ReadCurrent(p *xsx.PullParser) (Expr, error)

func ReadNext

func ReadNext(p *xsx.PullParser) (Expr, error)

type Sequence

type Sequence struct {
	Elems []Expr
	// contains filtered or unexported fields
}

func (*Sequence) Brace

func (s *Sequence) Brace() Brace

func (Sequence) Meta

func (e Sequence) Meta() bool

func (*Sequence) SetBrace

func (s *Sequence) SetBrace(b Brace)

func (*Sequence) SetMeta

func (e *Sequence) SetMeta(flag bool)

type State

type State struct {
	Results []Expr
	// contains filtered or unexported fields
}

func (*State) Atom

func (pst *State) Atom(isMeta bool, atom []byte, quoted bool)

func (*State) Begin

func (pst *State) Begin(isMeta bool, brace byte)

func (*State) End

func (pst *State) End(isMeta bool, brace byte)

Jump to

Keyboard shortcuts

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