grammar

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	SP = ' '
)

Variables

This section is empty.

Functions

func Alpha

func Alpha(p *parser.Parser) (*parser.Cursor, bool)

func AttrExp

func AttrExp(p *ast.Parser) (*ast.Node, error)

func AttrName

func AttrName(p *ast.Parser) (*ast.Node, error)

func AttrPath

func AttrPath(p *ast.Parser) (*ast.Node, error)

func Character

func Character(p *ast.Parser) (*ast.Node, error)

func CompareOp

func CompareOp(p *ast.Parser) (*ast.Node, error)

func CompareValue

func CompareValue(p *ast.Parser) (*ast.Node, error)

func Digit

func Digit(p *parser.Parser) (*parser.Cursor, bool)

func Digits

func Digits(p *ast.Parser) (*ast.Node, error)

func Escaped

func Escaped(p *ast.Parser) (*ast.Node, error)

func Exp

func Exp(p *ast.Parser) (*ast.Node, error)

func False

func False(p *ast.Parser) (*ast.Node, error)
Example
p, _ := ast.New([]byte("FaLSe"))
fmt.Println(False(p))
Output:

["False","FaLSe"] <nil>

func Filter

func Filter(p *ast.Parser) (*ast.Node, error)

func FilterAnd

func FilterAnd(p *ast.Parser) (*ast.Node, error)
Example
p := func(s string) {
	p, _ := ast.New([]byte(s))
	fmt.Println(Filter(p))
}
p("title pr and userType eq \"Employee\"")
p("userType eq \"Employee\" and emails[type eq \"work\" and value co \"@example.com\"]")
Output:

["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","title"]]]]],["AttrExp",[["AttrPath",[["AttrName","userType"]]],["CompareOp","eq"],["String","\"Employee\""]]]]]]] <nil>
["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","userType"]]],["CompareOp","eq"],["String","\"Employee\""]]],["ValuePath",[["AttrPath",[["AttrName","emails"]]],["ValueLogExpAnd",[["AttrExp",[["AttrPath",[["AttrName","type"]]],["CompareOp","eq"],["String","\"work\""]]],["AttrExp",[["AttrPath",[["AttrName","value"]]],["CompareOp","co"],["String","\"@example.com\""]]]]]]]]]]] <nil>

func FilterNot

func FilterNot(p *ast.Parser) (*ast.Node, error)
Example
p := func(s string) {
	p, _ := ast.New([]byte(s))
	fmt.Println(Filter(p))
}
p("userType ne \"Employee\" and not (emails co \"example.com\" or emails.value co \"example.org\")")
Output:

["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","userType"]]],["CompareOp","ne"],["String","\"Employee\""]]],["FilterNot",[["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","emails"]]],["CompareOp","co"],["String","\"example.com\""]]]]],["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","emails"],["AttrName","value"]]],["CompareOp","co"],["String","\"example.org\""]]]]]]]]]]]]] <nil>

func FilterOr

func FilterOr(p *ast.Parser) (*ast.Node, error)
Example
p := func(s string) {
	p, _ := ast.New([]byte(s))
	fmt.Println(Filter(p))
}
p("title pr or userType eq \"Intern\"")
p("emails[type eq \"work\" and value co \"@example.com\"] or ims[type eq \"xmpp\" and value co \"@foo.com\"]")
Output:

["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","title"]]]]]]],["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","userType"]]],["CompareOp","eq"],["String","\"Intern\""]]]]]]] <nil>
["FilterOr",[["FilterAnd",[["ValuePath",[["AttrPath",[["AttrName","emails"]]],["ValueLogExpAnd",[["AttrExp",[["AttrPath",[["AttrName","type"]]],["CompareOp","eq"],["String","\"work\""]]],["AttrExp",[["AttrPath",[["AttrName","value"]]],["CompareOp","co"],["String","\"@example.com\""]]]]]]]]],["FilterAnd",[["ValuePath",[["AttrPath",[["AttrName","ims"]]],["ValueLogExpAnd",[["AttrExp",[["AttrPath",[["AttrName","type"]]],["CompareOp","eq"],["String","\"xmpp\""]]],["AttrExp",[["AttrPath",[["AttrName","value"]]],["CompareOp","co"],["String","\"@foo.com\""]]]]]]]]]]] <nil>

func FilterParentheses

func FilterParentheses(p *ast.Parser) (*ast.Node, error)
Example
p := func(s string) {
	p, _ := ast.New([]byte(s))
	fmt.Println(Filter(p))
}
p("userType eq \"Employee\" and (emails.type eq \"work\")")
p("userType eq \"Employee\" and (emails co \"example.com\" or emails.value co \"example.org\")")
Output:

["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","userType"]]],["CompareOp","eq"],["String","\"Employee\""]]],["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","emails"],["AttrName","type"]]],["CompareOp","eq"],["String","\"work\""]]]]]]]]]]] <nil>
["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","userType"]]],["CompareOp","eq"],["String","\"Employee\""]]],["FilterOr",[["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","emails"]]],["CompareOp","co"],["String","\"example.com\""]]]]],["FilterAnd",[["AttrExp",[["AttrPath",[["AttrName","emails"],["AttrName","value"]]],["CompareOp","co"],["String","\"example.org\""]]]]]]]]]]] <nil>

func FilterValue

func FilterValue(p *ast.Parser) (*ast.Node, error)

func Frac

func Frac(p *ast.Parser) (*ast.Node, error)

func Int

func Int(p *ast.Parser) (*ast.Node, error)

func Minus

func Minus(p *ast.Parser) (*ast.Node, error)

func NameChar

func NameChar(p *ast.Parser) (*ast.Node, error)

func Null

func Null(p *ast.Parser) (*ast.Node, error)

func Number

func Number(p *ast.Parser) (*ast.Node, error)
Example
p, _ := ast.New([]byte("-10.0e+01"))
fmt.Println(Number(p))
Output:

["Number",[["Minus","-"],["Int","10"],["Frac",[["Digits","0"]]],["Exp",[["Sign","+"],["Digits","01"]]]]] <nil>

func Path

func Path(p *ast.Parser) (*ast.Node, error)
Example
p, _ := ast.New([]byte("members[value eq \"2819c223-7f76-453a-919d-413861904646\"].displayName"))
fmt.Println(Path(p))
Output:

["Path",[["ValuePath",[["AttrPath",[["AttrName","members"]]],["AttrExp",[["AttrPath",[["AttrName","value"]]],["CompareOp","eq"],["String","\"2819c223-7f76-453a-919d-413861904646\""]]]]],["AttrName","displayName"]]] <nil>

func Sign

func Sign(p *ast.Parser) (*ast.Node, error)

func String

func String(p *ast.Parser) (*ast.Node, error)
Example
p, _ := ast.New([]byte("\"2819c223-7f76-453a-919d-413861904646\""))
fmt.Println(String(p))
Output:

["String","\"2819c223-7f76-453a-919d-413861904646\""] <nil>
Example (Complex)
p, _ := ast.New([]byte("\"W/\\\"990-6468886345120203448\\\"\""))
fmt.Println(String(p))
Output:

["String","\"W/\\\"990-6468886345120203448\\\"\""] <nil>

func SubAttr

func SubAttr(p *ast.Parser) (*ast.Node, error)

func True

func True(p *ast.Parser) (*ast.Node, error)
Example
p, _ := ast.New([]byte("TRue"))
fmt.Println(True(p))
Output:

["True","TRue"] <nil>

func URI

func URI(p *ast.Parser) (*ast.Node, error)
Example
p, _ := ast.New([]byte("urn:ietf:params:scim:schemas:core:2.0:User:userName"))
fmt.Println(URI(p))
Output:

["URI","urn:ietf:params:scim:schemas:core:2.0:User:"] <nil>

func Unescaped

func Unescaped(p *ast.Parser) (*ast.Node, error)

func ValueFilter

func ValueFilter(p *ast.Parser) (*ast.Node, error)

func ValueFilterAll

func ValueFilterAll(p *ast.Parser) (*ast.Node, error)

func ValueFilterNot

func ValueFilterNot(p *ast.Parser) (*ast.Node, error)

func ValueLogExpAnd

func ValueLogExpAnd(p *ast.Parser) (*ast.Node, error)

func ValueLogExpOr

func ValueLogExpOr(p *ast.Parser) (*ast.Node, error)

func ValuePath

func ValuePath(p *ast.Parser) (*ast.Node, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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