Documentation
¶
Index ¶
- Constants
- func Parse(ctx *Context, p Parser) (Node, Error)
- type Context
- func (c *Context) CallCount() int
- func (c *Context) Error() Error
- func (c *Context) OverrideError(err Error)
- func (c *Context) Reader() Reader
- func (c *Context) RegisterCall()
- func (c *Context) ResultCache() ResultCache
- func (c *Context) SetError(pos Pos, cause error)
- func (c *Context) SetErrorf(pos Pos, format string, values ...interface{})
- type Error
- type File
- type FileSet
- type Interpreter
- type Node
- type Parser
- type Pos
- type Position
- type Reader
- type Result
- type ResultCache
Constants ¶
const NilPos = Pos(0)
NilPos represents an invalid position
const NilPosition = nilPosition(0)
NilPosition represents an invalid position
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶ added in v0.8.0
type Context struct {
// contains filtered or unexported fields
}
Context is the parsing context passed to all parsers
func NewContext ¶ added in v0.8.0
NewContext creates a new parsing context
func (*Context) Error ¶ added in v0.8.0
Error returns with the parse error with the highest position (if any)
func (*Context) OverrideError ¶ added in v0.8.0
OverrideError overrides any previously set errors
func (*Context) RegisterCall ¶ added in v0.8.0
func (c *Context) RegisterCall()
RegisterCall registers a call
func (*Context) ResultCache ¶ added in v0.8.0
func (c *Context) ResultCache() ResultCache
ResultCache returns with the result cache object
type Error ¶ added in v0.6.0
Error is an error with a position
func Evaluate ¶
Evaluate parses the given input and evaluates it. It expects a reader, the root parser and the evaluation context. If there are multiple possible parse trees only the first one is used for evaluation.
func NewError ¶ added in v0.6.0
NewError creates a new error with the given position If the passed error is already a parsley.Error it returns the original error as it should have already the correct position.
type File ¶ added in v0.6.0
File is an interface to translate a byte offset in a file to a position object
type FileSet ¶ added in v0.6.0
type FileSet struct {
// contains filtered or unexported fields
}
FileSet contains multiple files
func NewFileSet ¶ added in v0.6.0
NewFileSet creates a new file set
func (*FileSet) ErrorWithPosition ¶ added in v0.6.0
ErrorWithPosition creates an error with a human-readable position
type Interpreter ¶ added in v0.6.0
Interpreter defines an interface to evaluate AST nodes
type Node ¶ added in v0.6.0
type Node interface {
Token() string
Value(ctx interface{}) (interface{}, Error)
Pos() Pos
ReaderPos() Pos
}
Node represents an AST node
type Parser ¶ added in v0.6.0
type Parser interface {
Parse(ctx *Context, leftRecCtx data.IntMap, pos Pos) (Node, data.IntSet)
Name() string
}
Parser defines a parser interface
type Pos ¶ added in v0.6.0
type Pos int
Pos is a global offset in a file set which can be translated into a concrete file position
type ResultCache ¶ added in v0.8.0
ResultCache records information about parser calls
func NewResultCache ¶ added in v0.8.0
func NewResultCache() ResultCache
NewHistory creates a history instance