Documentation ¶
Index ¶
- func WasOk(_ interface{}, err error) bool
- func WasScannerError(v interface{}) error
- type Marker
- type Node
- type Record
- type Records
- type Scanner
- func (s *Scanner) EOF() bool
- func (s *Scanner) Error(err error, msg string) error
- func (s *Scanner) Literal(str string) (string, error)
- func (s *Scanner) Mark() Marker
- func (s *Scanner) MustProgress(m Marker) (Marker, error)
- func (s *Scanner) Pattern(re *regexp.Regexp) (string, error)
- func (s *Scanner) PreMark() Marker
- func (s *Scanner) Register(start Marker, object interface{})
- func (s *Scanner) Reset(start Marker)
- func (s *Scanner) Rune(r rune) (rune, error)
- func (s *Scanner) SetSkip(skipper Skipper) Skipper
- func (s *Scanner) Skip()
- func (s *Scanner) Trace(msg string)
- func (s *Scanner) Watermark() error
- type Skipper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WasOk ¶
WasOk is a helper function called by generated parser code. It is used to abandon the value result, and return true if there was no error. This is used in cases where the sub-parser is optional and the result is not needed.
func WasScannerError ¶
func WasScannerError(v interface{}) error
Types ¶
type Marker ¶
type Marker struct {
// contains filtered or unexported fields
}
Marker is a stored point in a scanner that can be reset to.
type Record ¶
Record is an entry in a Records list that holds a parse result along with its scan stream bounds.
type Records ¶
type Records []Record
Records is a list of Record objects that represent the ordered sequence of parse results.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner is a basic implementation of the functions used by generated parsers. It expects a the full byte slice of the source file.
func NewByteScanner ¶
NewByteScanner builds a scanner over an input byte slice. If records is nil, the cst will not be maintained, otherwise it will be filled in with the parse Record list.
func NewStringScanner ¶
NewStringScanner builds a scanner over an input string. If records is nil, the cst will not be maintained, otherwise it will be filled in with the parse Record list.
func (*Scanner) Error ¶
Error wraps an error and message into a new error that knows the scanner stream position.
func (*Scanner) Literal ¶
Rune is a parser for a literal string. If literal string is next in the stream, the string will be consumed an error will be nil. Otherwise an error will be returned and the value will be the empty string.
func (*Scanner) MustProgress ¶
MustProgress panics if the marker does not move forwards. Used to catch when the grammar is broken.
func (*Scanner) Pattern ¶
Pattern is a parser for a regular expression. If the pattern matches the start of the stream, the matching string will be consumed and returned. Otherwise an error will be returned and the value will be the empty string.
func (*Scanner) Register ¶
Register adds a node to the cst from the start marker to the current position.
func (*Scanner) Reset ¶
Reset puts the scanner back in the state it was when the start Marker was taken.
func (*Scanner) Rune ¶
Rune is a parser for a single rune. If the next rune in the stream is a match, the rune will be consumed an error will be nil. Otherwise an error will be returned. In either case, the requested rune is returned as the value.
func (*Scanner) Skip ¶
func (s *Scanner) Skip()
Skip invokes the current skip function if one is set.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package generator provides the functionality used by the lingo command to add generated parser functionality based on syntactically correct go code.
|
Package generator provides the functionality used by the lingo command to add generated parser functionality based on syntactically correct go code. |