Documentation ¶
Index ¶
- Variables
- func FromStringCheck(input string) (biscuit.Check, error)
- func FromStringFact(input string) (biscuit.Fact, error)
- func FromStringPolicy(input string) (biscuit.Policy, error)
- func FromStringRule(input string) (biscuit.Rule, error)
- type Allow
- type Bool
- type Check
- type CheckQuery
- type Comment
- type Deny
- type Expr1
- type Expr2
- type Expr3
- type Expr4
- type Expr5
- type ExprTerm
- type Expression
- type HexString
- type Length
- type MustParser
- type Negate
- type OpExpr1
- type OpExpr2
- type OpExpr3
- type OpExpr4
- type OpExpr5
- type Operator
- type Parens
- type Parser
- type Policy
- type Predicate
- type Rule
- type RuleElement
- type Set
- type Term
- type Unary
- type Value
- type Variable
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrVariableInFact = errors.New("parser: a fact cannot contain any variables") ErrVariableInSet = errors.New("parser: a set cannot contain any variables") )
View Source
var BiscuitLexerRules = []stateful.Rule{ {Name: "Keyword", Pattern: `check if|allow if|deny if`, Action: nil}, {Name: "Function", Pattern: `prefix|suffix|matches|length|contains`, Action: nil}, {Name: "Hex", Pattern: `hex:`, Action: nil}, {Name: "Dot", Pattern: `\.`, Action: nil}, {Name: "Arrow", Pattern: `<-`, Action: nil}, {Name: "Or", Pattern: `\|\|`, Action: nil}, {Name: "Operator", Pattern: `==|>=|<=|>|<|not|in`, Action: nil}, {Name: "Comment", Pattern: `//[^\n]*`, Action: nil}, {Name: "String", Pattern: `\"[^\"]*\"`, Action: nil}, {Name: "Variable", Pattern: `\$[a-zA-Z0-9_]+`, Action: nil}, {Name: "DateTime", Pattern: `\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(Z|([-+]\d\d:\d\d))?`}, {Name: "Int", Pattern: `[0-9]+`, Action: nil}, {Name: "Bool", Pattern: `true|false`, Action: nil}, {Name: "Ident", Pattern: `[a-zA-Z0-9_]+`, Action: nil}, {Name: "Whitespace", Pattern: `[ \t]+`, Action: nil}, {Name: "EOL", Pattern: `[\n\r]+`, Action: nil}, {Name: "Punct", Pattern: `[-[!@%^&#$*()+_={}\|:;"'<,>.?/]|]`, Action: nil}, }
View Source
var DefaultParserOptions = []participle.Option{ participle.Lexer(stateful.MustSimple(BiscuitLexerRules)), participle.UseLookahead(1), participle.Elide("Whitespace", "EOL"), participle.Unquote("String"), }
Functions ¶
func FromStringCheck ¶
func FromStringFact ¶
func FromStringPolicy ¶
func FromStringRule ¶
Types ¶
type Allow ¶
type Allow struct {
Queries []*CheckQuery `"allow if" @@ ( "or" @@ )*`
}
type Check ¶
type Check struct {
Queries []*CheckQuery `"check if" @@ ( "or" @@ )*`
}
type CheckQuery ¶
type CheckQuery struct {
Body []*RuleElement `@@ ("," @@)*`
}
func (*CheckQuery) ToBiscuit ¶
func (r *CheckQuery) ToBiscuit() (*biscuit.Rule, error)
type Deny ¶
type Deny struct {
Queries []*CheckQuery `"deny if" @@ ( "or" @@ )*`
}
type Expression ¶
func (*Expression) ToExpr ¶
func (e *Expression) ToExpr(expr *biscuit.Expression)
type MustParser ¶
type OpExpr5 ¶
type OpExpr5 struct { Operator Operator `Dot @("contains" | "starts_with" | "ends_with" | "matches" | "intersection" | "union" | "length")` Expression []*Expression `"(" @@* ")"` }
type Parens ¶
type Parens struct {
Expression *Expression `"(" @@ ")"`
}
type Parser ¶
type Rule ¶
type Rule struct { Comments []*Comment `@Comment*` Head *Predicate `@@` Body []*RuleElement `"<-" @@ ("," @@)*` }
type RuleElement ¶
type RuleElement struct { Predicate *Predicate `@@` Expression *Expression `|@@` }
type Term ¶
type Value ¶
type Value struct { Number *float64 ` @(Float|Int)` Variable *string `| @Ident` Subexpression *Expression `| "(" @@ ")"` }
Click to show internal directories.
Click to hide internal directories.