Documentation ¶
Overview ¶
Package terminal contains basic terminal parsers for text parsing
Index ¶
- Constants
- func Bool(schema interface{}, trueStr string, falseStr string) parser.Func
- func Char(schema interface{}) parser.Func
- func Float(schema interface{}) parser.Func
- func Integer(schema interface{}) parser.Func
- func Nil(schema interface{}, nilStr string) parser.Func
- func Op(op string) parser.Func
- func Regexp(schema interface{}, token string, name string, regexp string, groupIndex int) parser.Func
- func Rune(ch rune) parser.Func
- func String(schema interface{}, allowBackquote bool) parser.Func
- func TimeDuration(schema interface{}) parser.Func
- func Word(schema interface{}, word string, value interface{}) parser.Func
- type BoolNode
- type CharNode
- type FloatNode
- func (f *FloatNode) Pos() parsley.Pos
- func (f *FloatNode) ReaderPos() parsley.Pos
- func (f *FloatNode) Schema() interface{}
- func (f *FloatNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)
- func (f *FloatNode) String() string
- func (f *FloatNode) Token() string
- func (f *FloatNode) Value() interface{}
- type IntegerNode
- func (i *IntegerNode) Pos() parsley.Pos
- func (i *IntegerNode) ReaderPos() parsley.Pos
- func (i *IntegerNode) Schema() interface{}
- func (i *IntegerNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)
- func (i *IntegerNode) String() string
- func (i *IntegerNode) Token() string
- func (i *IntegerNode) Value() interface{}
- type NilNode
- type OpNode
- type StringNode
- func (s *StringNode) Pos() parsley.Pos
- func (s *StringNode) ReaderPos() parsley.Pos
- func (s *StringNode) Schema() interface{}
- func (s *StringNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)
- func (s *StringNode) String() string
- func (s *StringNode) Token() string
- func (s *StringNode) Value() interface{}
- type TimeDurationNode
- func (t *TimeDurationNode) Pos() parsley.Pos
- func (t *TimeDurationNode) ReaderPos() parsley.Pos
- func (t *TimeDurationNode) Schema() interface{}
- func (t *TimeDurationNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)
- func (t *TimeDurationNode) String() string
- func (t *TimeDurationNode) Token() string
- func (t *TimeDurationNode) Value() interface{}
Constants ¶
const TimeDurationType = "time.Duration"
TimeDurationType contains the time duration type's name
Variables ¶
This section is empty.
Functions ¶
func Regexp ¶
func Regexp(schema interface{}, token string, name string, regexp string, groupIndex int) parser.Func
Regexp matches the given regular expression The name variable is used for error messages, so it should be descriptive and make sense in the sentence "was expecting %s". The includeWhitespaces variable should be true if the reader is by default ignoring the whitespaces but you need to match those as well. If you are using capturing groups you can select which group to use as a value with the groupIdex variable.
func TimeDuration ¶ added in v0.17.0
TimeDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
Types ¶
type BoolNode ¶ added in v0.17.0
type BoolNode struct {
// contains filtered or unexported fields
}
BoolNode is a leaf node in the AST
func NewBoolNode ¶ added in v0.17.0
NewBoolNode creates a new BoolNode instance
func (*BoolNode) ReaderPos ¶ added in v0.17.0
ReaderPos returns the position of the first character immediately after this node
func (*BoolNode) Schema ¶ added in v0.17.0
func (b *BoolNode) Schema() interface{}
Schema returns the schema for the node's value
func (*BoolNode) SetReaderPos ¶ added in v0.17.0
SetReaderPos changes the reader position
type CharNode ¶ added in v0.17.0
type CharNode struct {
// contains filtered or unexported fields
}
CharNode is a leaf node in the AST
func NewCharNode ¶ added in v0.17.0
NewCharNode creates a new CharNode instance
func (*CharNode) ReaderPos ¶ added in v0.17.0
ReaderPos returns the position of the first character immediately after this node
func (*CharNode) Schema ¶ added in v0.17.0
func (c *CharNode) Schema() interface{}
Schema returns the schema for the node's value
func (*CharNode) SetReaderPos ¶ added in v0.17.0
SetReaderPos changes the reader position
type FloatNode ¶ added in v0.17.0
type FloatNode struct {
// contains filtered or unexported fields
}
FloatNode is a leaf node in the AST
func NewFloatNode ¶ added in v0.17.0
func NewFloatNode(schema interface{}, value float64, pos parsley.Pos, readerPos parsley.Pos) *FloatNode
NewFloatNode creates a new FloatNode instance
func (*FloatNode) ReaderPos ¶ added in v0.17.0
ReaderPos returns the position of the first character immediately after this node
func (*FloatNode) Schema ¶ added in v0.17.0
func (f *FloatNode) Schema() interface{}
Schema returns the schema for the node's value
func (*FloatNode) SetReaderPos ¶ added in v0.17.0
SetReaderPos changes the reader position
type IntegerNode ¶ added in v0.17.0
type IntegerNode struct {
// contains filtered or unexported fields
}
IntegerNode is a leaf node in the AST
func NewIntegerNode ¶ added in v0.17.0
func NewIntegerNode(schema interface{}, value int64, pos parsley.Pos, readerPos parsley.Pos) *IntegerNode
NewIntegerNode creates a new IntegerNode instance
func (*IntegerNode) Pos ¶ added in v0.17.0
func (i *IntegerNode) Pos() parsley.Pos
Pos returns the position
func (*IntegerNode) ReaderPos ¶ added in v0.17.0
func (i *IntegerNode) ReaderPos() parsley.Pos
ReaderPos returns the position of the first character immediately after this node
func (*IntegerNode) Schema ¶ added in v0.17.0
func (i *IntegerNode) Schema() interface{}
Schema returns the schema for the node's value
func (*IntegerNode) SetReaderPos ¶ added in v0.17.0
func (i *IntegerNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)
SetReaderPos changes the reader position
func (*IntegerNode) String ¶ added in v0.17.0
func (i *IntegerNode) String() string
String returns with a string representation of the node
func (*IntegerNode) Token ¶ added in v0.17.0
func (i *IntegerNode) Token() string
Token returns with the node token
func (*IntegerNode) Value ¶ added in v0.17.0
func (i *IntegerNode) Value() interface{}
Value returns with the value of the node
type NilNode ¶ added in v0.17.0
type NilNode struct {
// contains filtered or unexported fields
}
NilNode is a leaf node in the AST
func NewNilNode ¶ added in v0.17.0
NewNilNode creates a new NilNode instance
func (*NilNode) ReaderPos ¶ added in v0.17.0
ReaderPos returns the position of the first character immediately after this node
func (*NilNode) Schema ¶ added in v0.17.0
func (n *NilNode) Schema() interface{}
Schema returns the schema for the node's value
func (*NilNode) SetReaderPos ¶ added in v0.17.0
SetReaderPos changes the reader position
type OpNode ¶ added in v0.17.0
type OpNode struct {
// contains filtered or unexported fields
}
OpNode is a leaf node in the AST
func (*OpNode) ReaderPos ¶ added in v0.17.0
ReaderPos returns the position of the first character immediately after this node
func (*OpNode) Schema ¶ added in v0.17.0
func (o *OpNode) Schema() interface{}
Schema returns the schema for the node's value
func (*OpNode) SetReaderPos ¶ added in v0.17.0
SetReaderPos changes the reader position
type StringNode ¶ added in v0.17.0
type StringNode struct {
// contains filtered or unexported fields
}
StringNode is a leaf node in the AST
func NewStringNode ¶ added in v0.17.0
func NewStringNode(schema interface{}, value string, pos parsley.Pos, readerPos parsley.Pos) *StringNode
NewStringNode creates a new StringNode instance
func (*StringNode) Pos ¶ added in v0.17.0
func (s *StringNode) Pos() parsley.Pos
Pos returns the position
func (*StringNode) ReaderPos ¶ added in v0.17.0
func (s *StringNode) ReaderPos() parsley.Pos
ReaderPos returns the position of the first character immediately after this node
func (*StringNode) Schema ¶ added in v0.17.0
func (s *StringNode) Schema() interface{}
Schema returns the schema for the node's value
func (*StringNode) SetReaderPos ¶ added in v0.17.0
func (s *StringNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)
SetReaderPos changes the reader position
func (*StringNode) String ¶ added in v0.17.0
func (s *StringNode) String() string
String returns with a string representation of the node
func (*StringNode) Token ¶ added in v0.17.0
func (s *StringNode) Token() string
Token returns with the node token
func (*StringNode) Value ¶ added in v0.17.0
func (s *StringNode) Value() interface{}
Value returns with the value of the node
type TimeDurationNode ¶ added in v0.17.0
type TimeDurationNode struct {
// contains filtered or unexported fields
}
TimeDurationNode is a leaf node in the AST
func NewTimeDurationNode ¶ added in v0.17.0
func NewTimeDurationNode(schema interface{}, value time.Duration, pos parsley.Pos, readerPos parsley.Pos) *TimeDurationNode
NewTimeDurationNode creates a new TimeDurationNode instance
func (*TimeDurationNode) Pos ¶ added in v0.17.0
func (t *TimeDurationNode) Pos() parsley.Pos
Pos returns the position
func (*TimeDurationNode) ReaderPos ¶ added in v0.17.0
func (t *TimeDurationNode) ReaderPos() parsley.Pos
ReaderPos returns the position of the first character immediately after this node
func (*TimeDurationNode) Schema ¶ added in v0.17.0
func (t *TimeDurationNode) Schema() interface{}
Schema returns the schema for the node's value
func (*TimeDurationNode) SetReaderPos ¶ added in v0.17.0
func (t *TimeDurationNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)
SetReaderPos changes the reader position
func (*TimeDurationNode) String ¶ added in v0.17.0
func (t *TimeDurationNode) String() string
String returns with a string representation of the node
func (*TimeDurationNode) Token ¶ added in v0.17.0
func (t *TimeDurationNode) Token() string
Token returns with the node token
func (*TimeDurationNode) Value ¶ added in v0.17.0
func (t *TimeDurationNode) Value() interface{}
Value returns with the value of the node