Documentation ¶
Index ¶
- func Delete(root types.Node, path []types.PathElement, args ...any) error
- func Merge(root types.Node, path []types.PathElement, args ...any) error
- func Pop(root types.Node, path []types.PathElement, args ...any) error
- func Push(root types.Node, path []types.PathElement, args ...any) error
- func Set(root types.Node, path []types.PathElement, args ...any) error
- type Argument
- type ArrIndexPathElement
- type Boolean
- type Call
- type JSON
- type OpInstance
- type Operation
- type Parser
- type PathElement
- type StringPathElement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArrIndexPathElement ¶ added in v0.0.8
type ArrIndexPathElement int
func (*ArrIndexPathElement) Capture ¶ added in v0.0.8
func (b *ArrIndexPathElement) Capture(values []string) error
we need to do this because lexer will return text like `[0]` as a single token because of json
type Call ¶ added in v0.0.3
type Call struct { Name string `@Ident` Path []PathElement `"(" @@+` Arguments []Argument `( "," @@ )* ")"` }
type OpInstance ¶ added in v0.0.3
type OpInstance struct { Op Operation Name string Path types.PathElementSlice Args []any }
func (*OpInstance) String ¶ added in v0.0.3
func (op *OpInstance) String() string
type Parser ¶ added in v0.0.3
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) Parse ¶ added in v0.0.3
func (p *Parser) Parse(s string) (*OpInstance, error)
We should be parsing things like set(field, "123") // set a string set(field, 123) // set a number set(field, { a: 1 }) // assign an object to a field set(field, "{ a: 1 }") // assign an string to a field del(field.item) // delete a field Problems: - Only double quotes are supported for strings which makes passing valid json a pain - array indexes are not supported
type PathElement ¶ added in v0.0.3
type PathElement struct { // potential foot gun there, I did not want to have a // leading dot, but I could not write a grammar rule // to exclude it from the first match only, hence // I've made it optional ObjectField StringPathElement ` "."? (@String | @Ident)` ArrayIdx ArrIndexPathElement ` | @JSON` }
type StringPathElement ¶ added in v0.0.8
type StringPathElement string
func (*StringPathElement) Capture ¶ added in v0.0.8
func (b *StringPathElement) Capture(values []string) error
Click to show internal directories.
Click to hide internal directories.