Documentation
¶
Index ¶
- Constants
- Variables
- func IsRuntimeError(err error) bool
- func RuntimeErrorf(msg string, args ...interface{}) error
- type AccessExpression
- type AccessorExpression
- type DescentExpression
- type Empty
- type Expression
- type ExpressionStatement
- type Identifier
- type IndexExpression
- type InfixExpression
- type InfixFunc
- type Lexer
- type Operation
- type Parser
- type Path
- type Position
- type PrefixFunc
- type QueryExpression
- type RuntimeError
- type Scope
- type Scopes
- type String
- type StringScope
- type Token
- type TokenType
Constants ¶
const ( LOWEST = iota PCONDOR PCONDAND EQUALS LESSGREATER CALL INDEX )
Variables ¶
var (
ErrNotFound = errors.Errorf("not found")
)
var ( // UnknownToken can be used as a sentinel token for a unknown state. UnknownToken = Token{ Type: UNKNOWN, } )
Functions ¶
func IsRuntimeError ¶
IsRuntimeError returns if the error is an ErrInvalidIndex error
func RuntimeErrorf ¶
RuntimeErrorf defines a sentinel error for invalid index.
Types ¶
type AccessExpression ¶
type AccessExpression struct {
Token Token
Index Expression
}
AccessExpression represents an expression that is associated with an operator.
func (*AccessExpression) End ¶
func (ie *AccessExpression) End() Position
End returns the last position of the identifier.
func (*AccessExpression) Pos ¶
func (ie *AccessExpression) Pos() Position
Pos returns the first position of the identifier.
func (*AccessExpression) String ¶
func (ie *AccessExpression) String() string
type AccessorExpression ¶
type AccessorExpression struct {
Token Token
Right Expression
Left Expression
}
AccessorExpression represents an expression that is associated with an operator.
func (*AccessorExpression) End ¶
func (ie *AccessorExpression) End() Position
End returns the last position of the identifier.
func (*AccessorExpression) Pos ¶
func (ie *AccessorExpression) Pos() Position
Pos returns the first position of the identifier.
func (*AccessorExpression) String ¶
func (ie *AccessorExpression) String() string
type DescentExpression ¶
type DescentExpression struct {
Token Token
Right Expression
}
DescentExpression represents an descent expression
func (*DescentExpression) End ¶
func (i *DescentExpression) End() Position
End returns the last position of the descent expression.
func (*DescentExpression) Pos ¶
func (i *DescentExpression) Pos() Position
Pos returns the first position of the descent expression.
func (*DescentExpression) String ¶
func (i *DescentExpression) String() string
type Empty ¶
type Empty struct {
Token Token
}
Empty represents an empty expression
type Expression ¶
Expression defines a type of AST node for outlining an expression.
type ExpressionStatement ¶
type ExpressionStatement struct {
Token Token
Expression Expression
}
ExpressionStatement is a group of expressions that allows us to group a subset of expressions.
func (*ExpressionStatement) End ¶
func (es *ExpressionStatement) End() Position
End returns the last position of the expression statement.
func (*ExpressionStatement) Pos ¶
func (es *ExpressionStatement) Pos() Position
Pos returns the first position of the expression statement.
func (*ExpressionStatement) String ¶
func (es *ExpressionStatement) String() string
type Identifier ¶
type Identifier struct {
Token Token
}
Identifier represents an identifier for a given AST block
func (*Identifier) End ¶
func (i *Identifier) End() Position
End returns the last position of the identifier.
func (*Identifier) Pos ¶
func (i *Identifier) Pos() Position
Pos returns the first position of the identifier.
func (*Identifier) String ¶
func (i *Identifier) String() string
type IndexExpression ¶
type IndexExpression struct {
Token Token
Left Expression
Index Expression
}
IndexExpression represents an expression that is associated with an operator.
func (*IndexExpression) End ¶
func (ie *IndexExpression) End() Position
End returns the last position of the identifier.
func (*IndexExpression) Pos ¶
func (ie *IndexExpression) Pos() Position
Pos returns the first position of the identifier.
func (*IndexExpression) String ¶
func (ie *IndexExpression) String() string
type InfixExpression ¶
type InfixExpression struct {
Token Token
Operator string
Left Expression
Right Expression
}
InfixExpression represents an expression that is associated with an operator.
func (*InfixExpression) End ¶
func (ie *InfixExpression) End() Position
End returns the last position of the identifier.
func (*InfixExpression) Pos ¶
func (ie *InfixExpression) Pos() Position
Pos returns the first position of the identifier.
func (*InfixExpression) String ¶
func (ie *InfixExpression) String() string
type InfixFunc ¶
type InfixFunc func(Expression) Expression
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer takes a query and breaks it down into tokens that can be consumed at at later date. The lexer in question is lazy and requires the calling of next to move it forward.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Run ¶
func (p *Parser) Run() (*QueryExpression, error)
Run the parser to the end, which is either an EOF or an error.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path holds all the arguments for a given query.
type PrefixFunc ¶
type PrefixFunc func() Expression
type QueryExpression ¶
type QueryExpression struct {
Expressions []Expression
}
QueryExpression represents a query full of expressions
func (*QueryExpression) End ¶
func (e *QueryExpression) End() Position
End returns the last position of the query expression.
func (*QueryExpression) Pos ¶
func (e *QueryExpression) Pos() Position
Pos returns the first position of the query expression.
func (*QueryExpression) String ¶
func (e *QueryExpression) String() string
type RuntimeError ¶
type RuntimeError struct {
// contains filtered or unexported fields
}
RuntimeError creates an invalid error.
func (*RuntimeError) Error ¶
func (e *RuntimeError) Error() string
type Scope ¶
type Scope interface {
// GetAllIdents returns all the identifiers for a given scope.
GetAllIdents() []string
// GetIdentValue returns the value of the identifier in a given scope.
GetIdentValue(string) (Scope, error)
// RunOperation attempts to run an operation on a given scope
RunOperation(Operation, Scope) (Scope, error)
}
Scope is used to identify a given expression of a global mutated object.
type Scopes ¶
type Scopes struct {
// contains filtered or unexported fields
}
Scopes holds a list of scopes to walk over.
func (Scopes) GetAllIdents ¶
GetAllIdents returns all the identifiers for a given scope.
func (Scopes) GetIdentValue ¶
GetIdentValue returns the value of the identifier in a given scope.
type StringScope ¶
type StringScope struct {
// contains filtered or unexported fields
}
func MakeStringScope ¶
func MakeStringScope(v string) StringScope
func (StringScope) GetAllIdents ¶
func (s StringScope) GetAllIdents() []string
GetAllIdents returns all the identifiers for a given scope.
func (StringScope) GetIdentValue ¶
func (s StringScope) GetIdentValue(v string) (Scope, error)
GetIdentValue returns the value of the identifier in a given scope.
func (StringScope) RunOperation ¶
func (s StringScope) RunOperation(op Operation, scope Scope) (Scope, error)
RunOperation attempts to run an operation on a given scope
type Token ¶
Token defines a token found with in a query, along with the position and what type it is.