terminal

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: MPL-2.0 Imports: 10 Imported by: 3

Documentation

Overview

Package terminal contains basic terminal parsers for text parsing

Index

Constants

View Source
const TimeDurationType = "time.Duration"

TimeDurationType contains the time duration type's name

Variables

This section is empty.

Functions

func Bool

func Bool(schema interface{}, trueStr string, falseStr string) parser.Func

Bool matches a bool literal: true or false

func Char

func Char(schema interface{}) parser.Func

Char matches a character literal enclosed in single quotes

func Float

func Float(schema interface{}) parser.Func

Float matches a float literal

func Integer

func Integer(schema interface{}) parser.Func

Integer matches all integer numbers and zero with an optional -/+ sign

func Nil added in v0.6.0

func Nil(schema interface{}, nilStr string) parser.Func

Nil matches a nil literal

func Op added in v0.17.0

func Op(op string) parser.Func

Op matches the given operator

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 Rune

func Rune(ch rune) parser.Func

Rune matches the given character

func String

func String(schema interface{}, allowBackquote bool) parser.Func

String matches a string literal enclosed in double quotes

func TimeDuration added in v0.17.0

func TimeDuration(schema interface{}) parser.Func

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".

func Word

func Word(schema interface{}, word string, value interface{}) parser.Func

Word matches the given word

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

func NewBoolNode(schema interface{}, value bool, pos parsley.Pos, readerPos parsley.Pos) *BoolNode

NewBoolNode creates a new BoolNode instance

func (*BoolNode) Pos added in v0.17.0

func (b *BoolNode) Pos() parsley.Pos

Pos returns the position

func (*BoolNode) ReaderPos added in v0.17.0

func (b *BoolNode) ReaderPos() parsley.Pos

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

func (b *BoolNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)

SetReaderPos changes the reader position

func (*BoolNode) String added in v0.17.0

func (b *BoolNode) String() string

String returns with a string representation of the node

func (*BoolNode) Token added in v0.17.0

func (b *BoolNode) Token() string

Token returns with the node token

func (*BoolNode) Value added in v0.17.0

func (b *BoolNode) Value() interface{}

Value returns with the value of the node

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

func NewCharNode(schema interface{}, value rune, pos parsley.Pos, readerPos parsley.Pos) *CharNode

NewCharNode creates a new CharNode instance

func (*CharNode) Pos added in v0.17.0

func (c *CharNode) Pos() parsley.Pos

Pos returns the position

func (*CharNode) ReaderPos added in v0.17.0

func (c *CharNode) ReaderPos() parsley.Pos

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

func (c *CharNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)

SetReaderPos changes the reader position

func (*CharNode) String added in v0.17.0

func (c *CharNode) String() string

String returns with a string representation of the node

func (*CharNode) Token added in v0.17.0

func (c *CharNode) Token() string

Token returns with the node token

func (*CharNode) Value added in v0.17.0

func (c *CharNode) Value() interface{}

Value returns with the value of the node

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) Pos added in v0.17.0

func (f *FloatNode) Pos() parsley.Pos

Pos returns the position

func (*FloatNode) ReaderPos added in v0.17.0

func (f *FloatNode) ReaderPos() parsley.Pos

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

func (f *FloatNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)

SetReaderPos changes the reader position

func (*FloatNode) String added in v0.17.0

func (f *FloatNode) String() string

String returns with a string representation of the node

func (*FloatNode) Token added in v0.17.0

func (f *FloatNode) Token() string

Token returns with the node token

func (*FloatNode) Value added in v0.17.0

func (f *FloatNode) Value() interface{}

Value returns with the value of the node

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

func NewNilNode(schema interface{}, pos parsley.Pos, readerPos parsley.Pos) *NilNode

NewNilNode creates a new NilNode instance

func (*NilNode) Pos added in v0.17.0

func (n *NilNode) Pos() parsley.Pos

Pos returns the position

func (*NilNode) ReaderPos added in v0.17.0

func (n *NilNode) ReaderPos() parsley.Pos

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

func (n *NilNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)

SetReaderPos changes the reader position

func (*NilNode) String added in v0.17.0

func (n *NilNode) String() string

String returns with a string representation of the node

func (*NilNode) Token added in v0.17.0

func (n *NilNode) Token() string

Token returns with the node token

func (*NilNode) Value added in v0.17.0

func (n *NilNode) Value() interface{}

Value returns with the value of the node

type OpNode added in v0.17.0

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

OpNode is a leaf node in the AST

func NewOpNode added in v0.17.0

func NewOpNode(value string, pos parsley.Pos, readerPos parsley.Pos) *OpNode

NewOpNode creates a new OpNode instance

func (*OpNode) Pos added in v0.17.0

func (o *OpNode) Pos() parsley.Pos

Pos returns the position

func (*OpNode) ReaderPos added in v0.17.0

func (o *OpNode) ReaderPos() parsley.Pos

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

func (o *OpNode) SetReaderPos(fun func(parsley.Pos) parsley.Pos)

SetReaderPos changes the reader position

func (*OpNode) String added in v0.17.0

func (o *OpNode) String() string

String returns with a string representation of the node

func (*OpNode) Token added in v0.17.0

func (o *OpNode) Token() string

Token returns with the node token

func (*OpNode) Value added in v0.17.0

func (o *OpNode) Value() interface{}

Value returns with the value of the node

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

Jump to

Keyboard shortcuts

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