Documentation
¶
Overview ¶
Package parser parses and compiles the JSON query rules and evaluates them.
Index ¶
- Constants
- Variables
- func Evaluate(rule string, items map[string]any) bool
- func HasSegmentCall(rule string) bool
- func InitEmptyAttrPathContext(p *AttrPathContext)
- func InitEmptyListDoublesContext(p *ListDoublesContext)
- func InitEmptyListIntsContext(p *ListIntsContext)
- func InitEmptyListStringsContext(p *ListStringsContext)
- func InitEmptyQueryContext(p *QueryContext)
- func InitEmptySubAttrContext(p *SubAttrContext)
- func InitEmptySubListOfDoublesContext(p *SubListOfDoublesContext)
- func InitEmptySubListOfIntsContext(p *SubListOfIntsContext)
- func InitEmptySubListOfStringsContext(p *SubListOfStringsContext)
- func InitEmptyValueContext(p *ValueContext)
- func JsonQueryLexerInit()
- func JsonQueryParserInit()
- func ValidSegmentName(name string) bool
- type AttrPathContext
- func (s *AttrPathContext) ATTRNAME() antlr.TerminalNode
- func (s *AttrPathContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *AttrPathContext) GetParser() antlr.Parser
- func (s *AttrPathContext) GetRuleContext() antlr.RuleContext
- func (*AttrPathContext) IsAttrPathContext()
- func (s *AttrPathContext) SubAttr() ISubAttrContext
- func (s *AttrPathContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type BoolOperation
- type BooleanContext
- type CompareExpContext
- func (s *CompareExpContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *CompareExpContext) AllSP() []antlr.TerminalNode
- func (s *CompareExpContext) AttrPath() IAttrPathContext
- func (s *CompareExpContext) CO() antlr.TerminalNode
- func (s *CompareExpContext) EQ() antlr.TerminalNode
- func (s *CompareExpContext) EW() antlr.TerminalNode
- func (s *CompareExpContext) GE() antlr.TerminalNode
- func (s *CompareExpContext) GT() antlr.TerminalNode
- func (s *CompareExpContext) GetOp() antlr.Token
- func (s *CompareExpContext) GetRuleContext() antlr.RuleContext
- func (s *CompareExpContext) IN() antlr.TerminalNode
- func (s *CompareExpContext) LE() antlr.TerminalNode
- func (s *CompareExpContext) LT() antlr.TerminalNode
- func (s *CompareExpContext) NE() antlr.TerminalNode
- func (s *CompareExpContext) SP(i int) antlr.TerminalNode
- func (s *CompareExpContext) SW() antlr.TerminalNode
- func (s *CompareExpContext) SetOp(v antlr.Token)
- func (s *CompareExpContext) Value() IValueContext
- type DoubleContext
- type ErrVals
- type Evaluator
- func (e *Evaluator) HasSegments() bool
- func (e *Evaluator) LastDebugErr() error
- func (e *Evaluator) Process(items map[string]any) (ret bool, retErr error)
- func (e *Evaluator) ProcessSegments(items map[string]any, states []SegmentState) (ret Match, retErr error)
- func (e *Evaluator) ProcessUntilSegment(items map[string]any) (match, reached bool, retErr error)
- func (e *Evaluator) Reset()
- func (e *Evaluator) SegmentTerms() []SegmentTerm
- type FloatOperation
- func (o *FloatOperation) EQ(left, right Operand) (bool, error)
- func (o *FloatOperation) GE(left, right Operand) (bool, error)
- func (o *FloatOperation) GT(left, right Operand) (bool, error)
- func (*FloatOperation) IN(left, right Operand) (bool, error)
- func (o *FloatOperation) LE(left, right Operand) (bool, error)
- func (o *FloatOperation) LT(left, right Operand) (bool, error)
- func (o *FloatOperation) NE(left, right Operand) (bool, error)
- type IAttrPathContext
- type IListDoublesContext
- type IListIntsContext
- type IListStringsContext
- type IQueryContext
- type ISubAttrContext
- type ISubListOfDoublesContext
- type ISubListOfIntsContext
- type ISubListOfStringsContext
- type IValueContext
- type IntOperation
- func (o *IntOperation) EQ(left, right Operand) (bool, error)
- func (o *IntOperation) GE(left, right Operand) (bool, error)
- func (o *IntOperation) GT(left, right Operand) (bool, error)
- func (*IntOperation) IN(left, right Operand) (bool, error)
- func (o *IntOperation) LE(left, right Operand) (bool, error)
- func (o *IntOperation) LT(left, right Operand) (bool, error)
- func (o *IntOperation) NE(left, right Operand) (bool, error)
- type InvalidOperandError
- type JSONQueryVisitorImpl
- func (j *JSONQueryVisitorImpl) Visit(tree antlr.ParseTree) any
- func (j *JSONQueryVisitorImpl) VisitAttrPath(ctx *AttrPathContext) any
- func (j *JSONQueryVisitorImpl) VisitBoolean(ctx *BooleanContext) any
- func (j *JSONQueryVisitorImpl) VisitCompareExp(ctx *CompareExpContext) any
- func (j *JSONQueryVisitorImpl) VisitDouble(ctx *DoubleContext) any
- func (j *JSONQueryVisitorImpl) VisitListDoubles(ctx *ListDoublesContext) any
- func (j *JSONQueryVisitorImpl) VisitListInts(ctx *ListIntsContext) any
- func (j *JSONQueryVisitorImpl) VisitListOfDoubles(ctx *ListOfDoublesContext) any
- func (j *JSONQueryVisitorImpl) VisitListOfInts(ctx *ListOfIntsContext) any
- func (j *JSONQueryVisitorImpl) VisitListOfStrings(ctx *ListOfStringsContext) any
- func (j *JSONQueryVisitorImpl) VisitListStrings(ctx *ListStringsContext) any
- func (j *JSONQueryVisitorImpl) VisitLogicalExp(ctx *LogicalExpContext) any
- func (j *JSONQueryVisitorImpl) VisitLong(ctx *LongContext) any
- func (j *JSONQueryVisitorImpl) VisitNull(_ *NullContext) any
- func (j *JSONQueryVisitorImpl) VisitParenExp(ctx *ParenExpContext) any
- func (j *JSONQueryVisitorImpl) VisitPresentExp(ctx *PresentExpContext) any
- func (j *JSONQueryVisitorImpl) VisitString(ctx *StringContext) any
- func (j *JSONQueryVisitorImpl) VisitSubAttr(ctx *SubAttrContext) any
- func (j *JSONQueryVisitorImpl) VisitSubListOfDoubles(ctx *SubListOfDoublesContext) any
- func (j *JSONQueryVisitorImpl) VisitSubListOfInts(ctx *SubListOfIntsContext) any
- func (j *JSONQueryVisitorImpl) VisitSubListOfStrings(ctx *SubListOfStringsContext) any
- func (j *JSONQueryVisitorImpl) VisitVersion(ctx *VersionContext) any
- type JsonQueryLexer
- type JsonQueryParser
- func (p *JsonQueryParser) AttrPath() (localctx IAttrPathContext)
- func (p *JsonQueryParser) ListDoubles() (localctx IListDoublesContext)
- func (p *JsonQueryParser) ListInts() (localctx IListIntsContext)
- func (p *JsonQueryParser) ListStrings() (localctx IListStringsContext)
- func (p *JsonQueryParser) Query() (localctx IQueryContext)
- func (p *JsonQueryParser) Query_Sempred(localctx antlr.RuleContext, predIndex int) bool
- func (p *JsonQueryParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool
- func (p *JsonQueryParser) SubAttr() (localctx ISubAttrContext)
- func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext)
- func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext)
- func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext)
- func (p *JsonQueryParser) Value() (localctx IValueContext)
- type JsonQueryVisitor
- type ListDoublesContext
- func (s *ListDoublesContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *ListDoublesContext) GetParser() antlr.Parser
- func (s *ListDoublesContext) GetRuleContext() antlr.RuleContext
- func (*ListDoublesContext) IsListDoublesContext()
- func (s *ListDoublesContext) SubListOfDoubles() ISubListOfDoublesContext
- func (s *ListDoublesContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type ListIntsContext
- func (s *ListIntsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *ListIntsContext) GetParser() antlr.Parser
- func (s *ListIntsContext) GetRuleContext() antlr.RuleContext
- func (*ListIntsContext) IsListIntsContext()
- func (s *ListIntsContext) SubListOfInts() ISubListOfIntsContext
- func (s *ListIntsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type ListOfDoublesContext
- type ListOfIntsContext
- type ListOfStringsContext
- type ListStringsContext
- func (s *ListStringsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *ListStringsContext) GetParser() antlr.Parser
- func (s *ListStringsContext) GetRuleContext() antlr.RuleContext
- func (*ListStringsContext) IsListStringsContext()
- func (s *ListStringsContext) SubListOfStrings() ISubListOfStringsContext
- func (s *ListStringsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type LogicalExpContext
- func (s *LogicalExpContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *LogicalExpContext) AllQuery() []IQueryContext
- func (s *LogicalExpContext) AllSP() []antlr.TerminalNode
- func (s *LogicalExpContext) GetRuleContext() antlr.RuleContext
- func (s *LogicalExpContext) LOGICAL_OPERATOR() antlr.TerminalNode
- func (s *LogicalExpContext) Query(i int) IQueryContext
- func (s *LogicalExpContext) SP(i int) antlr.TerminalNode
- type LongContext
- type Match
- type NestedError
- type NullContext
- type NullOperation
- func (*NullOperation) CO(_, _ Operand) (bool, error)
- func (*NullOperation) EQ(left, _ Operand) (bool, error)
- func (*NullOperation) EW(_, _ Operand) (bool, error)
- func (*NullOperation) GE(_, _ Operand) (bool, error)
- func (*NullOperation) GT(_, _ Operand) (bool, error)
- func (*NullOperation) IN(_, _ Operand) (bool, error)
- func (*NullOperation) LE(_, _ Operand) (bool, error)
- func (*NullOperation) LT(_, _ Operand) (bool, error)
- func (*NullOperation) NE(left, _ Operand) (bool, error)
- func (*NullOperation) SW(_, _ Operand) (bool, error)
- type Operand
- type Operation
- type ParenExpContext
- func (s *ParenExpContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *ParenExpContext) AllSP() []antlr.TerminalNode
- func (s *ParenExpContext) GetRuleContext() antlr.RuleContext
- func (s *ParenExpContext) NOT() antlr.TerminalNode
- func (s *ParenExpContext) Query() IQueryContext
- func (s *ParenExpContext) SP(i int) antlr.TerminalNode
- type PresentExpContext
- type QueryContext
- type SegmentError
- type SegmentState
- type SegmentTerm
- type StringContext
- type StringOperation
- func (o *StringOperation) CO(left, right Operand) (bool, error)
- func (o *StringOperation) EQ(left, right Operand) (bool, error)
- func (o *StringOperation) EW(left, right Operand) (bool, error)
- func (o *StringOperation) GE(left, right Operand) (bool, error)
- func (o *StringOperation) GT(left, right Operand) (bool, error)
- func (o *StringOperation) IN(left, right Operand) (bool, error)
- func (o *StringOperation) LE(left, right Operand) (bool, error)
- func (o *StringOperation) LT(left, right Operand) (bool, error)
- func (o *StringOperation) NE(left, right Operand) (bool, error)
- func (o *StringOperation) SW(left, right Operand) (bool, error)
- type SubAttrContext
- func (s *SubAttrContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *SubAttrContext) AttrPath() IAttrPathContext
- func (s *SubAttrContext) GetParser() antlr.Parser
- func (s *SubAttrContext) GetRuleContext() antlr.RuleContext
- func (*SubAttrContext) IsSubAttrContext()
- func (s *SubAttrContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type SubListOfDoublesContext
- func (s *SubListOfDoublesContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *SubListOfDoublesContext) COMMA() antlr.TerminalNode
- func (s *SubListOfDoublesContext) DOUBLE() antlr.TerminalNode
- func (s *SubListOfDoublesContext) GetParser() antlr.Parser
- func (s *SubListOfDoublesContext) GetRuleContext() antlr.RuleContext
- func (*SubListOfDoublesContext) IsSubListOfDoublesContext()
- func (s *SubListOfDoublesContext) SubListOfDoubles() ISubListOfDoublesContext
- func (s *SubListOfDoublesContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type SubListOfIntsContext
- func (s *SubListOfIntsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *SubListOfIntsContext) COMMA() antlr.TerminalNode
- func (s *SubListOfIntsContext) GetParser() antlr.Parser
- func (s *SubListOfIntsContext) GetRuleContext() antlr.RuleContext
- func (s *SubListOfIntsContext) INT() antlr.TerminalNode
- func (*SubListOfIntsContext) IsSubListOfIntsContext()
- func (s *SubListOfIntsContext) SubListOfInts() ISubListOfIntsContext
- func (s *SubListOfIntsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type SubListOfStringsContext
- func (s *SubListOfStringsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
- func (s *SubListOfStringsContext) COMMA() antlr.TerminalNode
- func (s *SubListOfStringsContext) GetParser() antlr.Parser
- func (s *SubListOfStringsContext) GetRuleContext() antlr.RuleContext
- func (*SubListOfStringsContext) IsSubListOfStringsContext()
- func (s *SubListOfStringsContext) STRING() antlr.TerminalNode
- func (s *SubListOfStringsContext) SubListOfStrings() ISubListOfStringsContext
- func (s *SubListOfStringsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
- type ValueContext
- type VersionContext
- type VersionOperation
- func (v *VersionOperation) EQ(left, right Operand) (bool, error)
- func (v *VersionOperation) GE(left, right Operand) (bool, error)
- func (v *VersionOperation) GT(left, right Operand) (bool, error)
- func (v *VersionOperation) LE(left, right Operand) (bool, error)
- func (v *VersionOperation) LT(left, right Operand) (bool, error)
- func (v *VersionOperation) NE(left, right Operand) (bool, error)
Constants ¶
const ( JsonQueryLexerT__0 = 1 JsonQueryLexerT__1 = 2 JsonQueryLexerT__2 = 3 JsonQueryLexerT__3 = 4 JsonQueryLexerT__4 = 5 JsonQueryLexerT__5 = 6 JsonQueryLexerT__6 = 7 JsonQueryLexerNOT = 8 JsonQueryLexerLOGICAL_OPERATOR = 9 JsonQueryLexerBOOLEAN = 10 JsonQueryLexerNULL = 11 JsonQueryLexerIN = 12 JsonQueryLexerEQ = 13 JsonQueryLexerNE = 14 JsonQueryLexerGT = 15 JsonQueryLexerLT = 16 JsonQueryLexerGE = 17 JsonQueryLexerLE = 18 JsonQueryLexerCO = 19 JsonQueryLexerSW = 20 JsonQueryLexerEW = 21 JsonQueryLexerATTRNAME = 22 JsonQueryLexerVERSION = 23 JsonQueryLexerSTRING = 24 JsonQueryLexerDOUBLE = 25 JsonQueryLexerINT = 26 JsonQueryLexerEXP = 27 JsonQueryLexerNEWLINE = 28 JsonQueryLexerCOMMA = 29 JsonQueryLexerSP = 30 )
JsonQueryLexer tokens.
const ( JsonQueryParserEOF = antlr.TokenEOF JsonQueryParserT__0 = 1 JsonQueryParserT__1 = 2 JsonQueryParserT__2 = 3 JsonQueryParserT__3 = 4 JsonQueryParserT__4 = 5 JsonQueryParserT__5 = 6 JsonQueryParserT__6 = 7 JsonQueryParserNOT = 8 JsonQueryParserLOGICAL_OPERATOR = 9 JsonQueryParserBOOLEAN = 10 JsonQueryParserNULL = 11 JsonQueryParserIN = 12 JsonQueryParserEQ = 13 JsonQueryParserNE = 14 JsonQueryParserGT = 15 JsonQueryParserLT = 16 JsonQueryParserGE = 17 JsonQueryParserLE = 18 JsonQueryParserCO = 19 JsonQueryParserSW = 20 JsonQueryParserEW = 21 JsonQueryParserATTRNAME = 22 JsonQueryParserVERSION = 23 JsonQueryParserSTRING = 24 JsonQueryParserDOUBLE = 25 JsonQueryParserINT = 26 JsonQueryParserEXP = 27 JsonQueryParserNEWLINE = 28 JsonQueryParserCOMMA = 29 JsonQueryParserSP = 30 )
JsonQueryParser tokens.
const ( JsonQueryParserRULE_query = 0 JsonQueryParserRULE_attrPath = 1 JsonQueryParserRULE_subAttr = 2 JsonQueryParserRULE_value = 3 JsonQueryParserRULE_listStrings = 4 JsonQueryParserRULE_subListOfStrings = 5 JsonQueryParserRULE_listDoubles = 6 JsonQueryParserRULE_subListOfDoubles = 7 JsonQueryParserRULE_listInts = 8 JsonQueryParserRULE_subListOfInts = 9 )
JsonQueryParser rules.
const ( // MaxSegmentNameLen is the longest name of a segment. MaxSegmentNameLen = 64 // MaxSegmentTerms is the most segment terms (distinct attribute and segment pairs) of one rule. MaxSegmentTerms = 32 )
Variables ¶
var ( ErrInvalidOperation = errors.New("Invalid operation on the type") //nolint:staticcheck // ST1005: observable text ErrEvalOperandMissing = errors.New("Operand not present") )
The error text is observable by callers (it is wrapped into the query validation error and logged), so it keeps its original capitalization.
var ( // ErrSegmentSyntax is wrapped by the errors of a segment() term that is not valid. ErrSegmentSyntax = errors.New("invalid segment() term") // ErrSegmentsNotResolved is returned by Process for a rule that has segment terms: such a rule can only be // evaluated with ProcessSegments, because the membership of the attributes is an input of the evaluation. ErrSegmentsNotResolved = errors.New("the rule has segment() terms: evaluate it with ProcessSegments") // ErrSegmentStates is returned by ProcessSegments when it is not given one state for each segment term. ErrSegmentStates = errors.New("one segment state is needed for each segment term") )
var JsonQueryLexerLexerStaticData struct { ChannelNames []string ModeNames []string LiteralNames []string SymbolicNames []string RuleNames []string PredictionContextCache *antlr.PredictionContextCache // contains filtered or unexported fields }
var JsonQueryParserStaticData struct { LiteralNames []string SymbolicNames []string RuleNames []string PredictionContextCache *antlr.PredictionContextCache // contains filtered or unexported fields }
Functions ¶
func Evaluate ¶
Evaluate reports whether the rule matches the items, and false if the rule does not compile.
func HasSegmentCall ¶ added in v0.2.0
HasSegmentCall reports whether the rule calls segment(), validly or not. It is the test that the evaluator applies to decide that a rule has segment terms, so a word segment that is only an attribute does not count.
func InitEmptyAttrPathContext ¶
func InitEmptyAttrPathContext(p *AttrPathContext)
func InitEmptyListDoublesContext ¶
func InitEmptyListDoublesContext(p *ListDoublesContext)
func InitEmptyListIntsContext ¶
func InitEmptyListIntsContext(p *ListIntsContext)
func InitEmptyListStringsContext ¶
func InitEmptyListStringsContext(p *ListStringsContext)
func InitEmptyQueryContext ¶
func InitEmptyQueryContext(p *QueryContext)
func InitEmptySubAttrContext ¶
func InitEmptySubAttrContext(p *SubAttrContext)
func InitEmptySubListOfDoublesContext ¶
func InitEmptySubListOfDoublesContext(p *SubListOfDoublesContext)
func InitEmptySubListOfIntsContext ¶
func InitEmptySubListOfIntsContext(p *SubListOfIntsContext)
func InitEmptySubListOfStringsContext ¶
func InitEmptySubListOfStringsContext(p *SubListOfStringsContext)
func InitEmptyValueContext ¶
func InitEmptyValueContext(p *ValueContext)
func JsonQueryLexerInit ¶
func JsonQueryLexerInit()
JsonQueryLexerInit initializes any static state used to implement JsonQueryLexer. By default the static state used to implement the lexer is lazily initialized during the first call to NewJsonQueryLexer(). You can call this function if you wish to initialize the static state ahead of time.
func JsonQueryParserInit ¶
func JsonQueryParserInit()
JsonQueryParserInit initializes any static state used to implement JsonQueryParser. By default the static state used to implement the parser is lazily initialized during the first call to NewJsonQueryParser(). You can call this function if you wish to initialize the static state ahead of time.
func ValidSegmentName ¶ added in v0.2.0
ValidSegmentName reports whether name is a segment name: 1 to 64 characters of a-z, 0-9, "_" and "-".
Types ¶
type AttrPathContext ¶
type AttrPathContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewAttrPathContext ¶
func NewAttrPathContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *AttrPathContext
func NewEmptyAttrPathContext ¶
func NewEmptyAttrPathContext() *AttrPathContext
func (*AttrPathContext) ATTRNAME ¶
func (s *AttrPathContext) ATTRNAME() antlr.TerminalNode
func (*AttrPathContext) Accept ¶
func (s *AttrPathContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*AttrPathContext) GetParser ¶
func (s *AttrPathContext) GetParser() antlr.Parser
func (*AttrPathContext) GetRuleContext ¶
func (s *AttrPathContext) GetRuleContext() antlr.RuleContext
func (*AttrPathContext) IsAttrPathContext ¶
func (*AttrPathContext) IsAttrPathContext()
func (*AttrPathContext) SubAttr ¶
func (s *AttrPathContext) SubAttr() ISubAttrContext
func (*AttrPathContext) ToStringTree ¶
func (s *AttrPathContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type BoolOperation ¶
type BoolOperation struct {
NullOperation
}
BoolOperation compares boolean operands for equality and inequality.
type BooleanContext ¶
type BooleanContext struct {
ValueContext
}
func NewBooleanContext ¶
func NewBooleanContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *BooleanContext
func (*BooleanContext) Accept ¶
func (s *BooleanContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*BooleanContext) BOOLEAN ¶
func (s *BooleanContext) BOOLEAN() antlr.TerminalNode
func (*BooleanContext) GetRuleContext ¶
func (s *BooleanContext) GetRuleContext() antlr.RuleContext
type CompareExpContext ¶
type CompareExpContext struct {
QueryContext
// contains filtered or unexported fields
}
func NewCompareExpContext ¶
func NewCompareExpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *CompareExpContext
func (*CompareExpContext) Accept ¶
func (s *CompareExpContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*CompareExpContext) AllSP ¶
func (s *CompareExpContext) AllSP() []antlr.TerminalNode
func (*CompareExpContext) AttrPath ¶
func (s *CompareExpContext) AttrPath() IAttrPathContext
func (*CompareExpContext) CO ¶
func (s *CompareExpContext) CO() antlr.TerminalNode
func (*CompareExpContext) EQ ¶
func (s *CompareExpContext) EQ() antlr.TerminalNode
func (*CompareExpContext) EW ¶
func (s *CompareExpContext) EW() antlr.TerminalNode
func (*CompareExpContext) GE ¶
func (s *CompareExpContext) GE() antlr.TerminalNode
func (*CompareExpContext) GT ¶
func (s *CompareExpContext) GT() antlr.TerminalNode
func (*CompareExpContext) GetOp ¶
func (s *CompareExpContext) GetOp() antlr.Token
func (*CompareExpContext) GetRuleContext ¶
func (s *CompareExpContext) GetRuleContext() antlr.RuleContext
func (*CompareExpContext) IN ¶
func (s *CompareExpContext) IN() antlr.TerminalNode
func (*CompareExpContext) LE ¶
func (s *CompareExpContext) LE() antlr.TerminalNode
func (*CompareExpContext) LT ¶
func (s *CompareExpContext) LT() antlr.TerminalNode
func (*CompareExpContext) NE ¶
func (s *CompareExpContext) NE() antlr.TerminalNode
func (*CompareExpContext) SP ¶
func (s *CompareExpContext) SP(i int) antlr.TerminalNode
func (*CompareExpContext) SW ¶
func (s *CompareExpContext) SW() antlr.TerminalNode
func (*CompareExpContext) SetOp ¶
func (s *CompareExpContext) SetOp(v antlr.Token)
func (*CompareExpContext) Value ¶
func (s *CompareExpContext) Value() IValueContext
type DoubleContext ¶
type DoubleContext struct {
ValueContext
}
func NewDoubleContext ¶
func NewDoubleContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *DoubleContext
func (*DoubleContext) Accept ¶
func (s *DoubleContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*DoubleContext) DOUBLE ¶
func (s *DoubleContext) DOUBLE() antlr.TerminalNode
func (*DoubleContext) GetRuleContext ¶
func (s *DoubleContext) GetRuleContext() antlr.RuleContext
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator evaluates a single parsed rule against attribute maps.
It is safe for concurrent Process calls. It must not be copied after first use: it holds a sync.Once and an atomic.Pointer, and go vet's copylocks check flags copies. Each call clears LastDebugErr on entry; once calls quiesce it holds the error of the last call to finish (nil if that call was clean or panicked). Reset clears it.
func NewEvaluator ¶
NewEvaluator parses and compiles a JSON query rule into an Evaluator.
func (*Evaluator) HasSegments ¶ added in v0.2.0
HasSegments reports whether the rule has segment() terms. Such a rule is evaluated by ProcessSegments.
func (*Evaluator) LastDebugErr ¶
LastDebugErr returns the last debug error recorded by the evaluator, or nil if there is none.
func (*Evaluator) Process ¶
Process evaluates items against the rule. The rule is compiled on first use.
func (*Evaluator) ProcessSegments ¶ added in v0.2.0
func (e *Evaluator) ProcessSegments(items map[string]any, states []SegmentState) (ret Match, retErr error)
ProcessSegments is the second pass of a rule with segment terms: states[i] is the membership for SegmentTerms()[i]. It evaluates the whole rule left to right, three-valued: the result is MatchUnknown when it depends on a term whose state is SegmentUnknown. An operand that is reached is evaluated, whatever the state of an earlier term, and an error of such an operand is the error of the rule. Like Process, it is safe for concurrent use and it never modifies items or states.
func (*Evaluator) ProcessUntilSegment ¶ added in v0.2.0
ProcessUntilSegment is the first pass of a rule with segment terms. It evaluates the rule as Process does (two valued, left to right, the short circuit of "and" and "or") and stops at the first segment term it reaches: reached is then true and the other results mean nothing; an error met before that term is the error of the rule and reached is false. When it returns reached false the rule is decided without any membership, and match and err are what Process returns for a rule without segment terms.
func (*Evaluator) Reset ¶
func (e *Evaluator) Reset()
Reset clears the last debug error recorded by the evaluator.
func (*Evaluator) SegmentTerms ¶ added in v0.2.0
func (e *Evaluator) SegmentTerms() []SegmentTerm
SegmentTerms returns the segment terms of the rule, in the order of the states ProcessSegments reads. The result is shared: it must not be modified. It is nil when the rule has no segment term.
type FloatOperation ¶
type FloatOperation struct {
NullOperation
}
FloatOperation compares floating-point operands.
func (*FloatOperation) EQ ¶
func (o *FloatOperation) EQ(left, right Operand) (bool, error)
EQ reports whether two floating-point operands are equal.
func (*FloatOperation) GE ¶
func (o *FloatOperation) GE(left, right Operand) (bool, error)
GE reports whether the left operand is greater than or equal to the right operand.
func (*FloatOperation) GT ¶
func (o *FloatOperation) GT(left, right Operand) (bool, error)
GT reports whether the left operand is greater than the right operand.
func (*FloatOperation) IN ¶
func (*FloatOperation) IN(left, right Operand) (bool, error)
IN reports whether the left operand is one of the values in the right operand.
func (*FloatOperation) LE ¶
func (o *FloatOperation) LE(left, right Operand) (bool, error)
LE reports whether the left operand is less than or equal to the right operand.
type IAttrPathContext ¶
type IAttrPathContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// Getter signatures
ATTRNAME() antlr.TerminalNode
SubAttr() ISubAttrContext
// IsAttrPathContext differentiates from other interfaces.
IsAttrPathContext()
}
IAttrPathContext is an interface to support dynamic dispatch.
type IListDoublesContext ¶
type IListDoublesContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// Getter signatures
SubListOfDoubles() ISubListOfDoublesContext
// IsListDoublesContext differentiates from other interfaces.
IsListDoublesContext()
}
IListDoublesContext is an interface to support dynamic dispatch.
type IListIntsContext ¶
type IListIntsContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// Getter signatures
SubListOfInts() ISubListOfIntsContext
// IsListIntsContext differentiates from other interfaces.
IsListIntsContext()
}
IListIntsContext is an interface to support dynamic dispatch.
type IListStringsContext ¶
type IListStringsContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// Getter signatures
SubListOfStrings() ISubListOfStringsContext
// IsListStringsContext differentiates from other interfaces.
IsListStringsContext()
}
IListStringsContext is an interface to support dynamic dispatch.
type IQueryContext ¶
type IQueryContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsQueryContext differentiates from other interfaces.
IsQueryContext()
}
IQueryContext is an interface to support dynamic dispatch.
type ISubAttrContext ¶
type ISubAttrContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// Getter signatures
AttrPath() IAttrPathContext
// IsSubAttrContext differentiates from other interfaces.
IsSubAttrContext()
}
ISubAttrContext is an interface to support dynamic dispatch.
type ISubListOfDoublesContext ¶
type ISubListOfDoublesContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// Getter signatures
DOUBLE() antlr.TerminalNode
COMMA() antlr.TerminalNode
SubListOfDoubles() ISubListOfDoublesContext
// IsSubListOfDoublesContext differentiates from other interfaces.
IsSubListOfDoublesContext()
}
ISubListOfDoublesContext is an interface to support dynamic dispatch.
type ISubListOfIntsContext ¶
type ISubListOfIntsContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// Getter signatures
INT() antlr.TerminalNode
COMMA() antlr.TerminalNode
SubListOfInts() ISubListOfIntsContext
// IsSubListOfIntsContext differentiates from other interfaces.
IsSubListOfIntsContext()
}
ISubListOfIntsContext is an interface to support dynamic dispatch.
type ISubListOfStringsContext ¶
type ISubListOfStringsContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// Getter signatures
STRING() antlr.TerminalNode
COMMA() antlr.TerminalNode
SubListOfStrings() ISubListOfStringsContext
// IsSubListOfStringsContext differentiates from other interfaces.
IsSubListOfStringsContext()
}
ISubListOfStringsContext is an interface to support dynamic dispatch.
type IValueContext ¶
type IValueContext interface {
antlr.ParserRuleContext
// GetParser returns the parser.
GetParser() antlr.Parser
// IsValueContext differentiates from other interfaces.
IsValueContext()
}
IValueContext is an interface to support dynamic dispatch.
type IntOperation ¶
type IntOperation struct {
NullOperation
}
IntOperation compares integer operands.
func (*IntOperation) EQ ¶
func (o *IntOperation) EQ(left, right Operand) (bool, error)
EQ reports whether two integer operands are equal.
func (*IntOperation) GE ¶
func (o *IntOperation) GE(left, right Operand) (bool, error)
GE reports whether the left operand is greater than or equal to the right operand.
func (*IntOperation) GT ¶
func (o *IntOperation) GT(left, right Operand) (bool, error)
GT reports whether the left operand is greater than the right operand.
func (*IntOperation) IN ¶
func (*IntOperation) IN(left, right Operand) (bool, error)
IN reports whether the left operand is one of the values in the right operand.
func (*IntOperation) LE ¶
func (o *IntOperation) LE(left, right Operand) (bool, error)
LE reports whether the left operand is less than or equal to the right operand.
type InvalidOperandError ¶
type InvalidOperandError struct {
Val any
// contains filtered or unexported fields
}
InvalidOperandError reports an operand whose type does not match the operation.
func (*InvalidOperandError) Error ¶
func (e *InvalidOperandError) Error() string
type JSONQueryVisitorImpl ¶
type JSONQueryVisitorImpl struct {
antlr.ParseTreeVisitor
// contains filtered or unexported fields
}
JSONQueryVisitorImpl walks a parsed JSON query tree and evaluates it against an item.
func NewJSONQueryVisitorImpl ¶
func NewJSONQueryVisitorImpl(item map[string]any) *JSONQueryVisitorImpl
NewJSONQueryVisitorImpl returns a visitor that evaluates queries against item.
func (*JSONQueryVisitorImpl) Visit ¶
func (j *JSONQueryVisitorImpl) Visit(tree antlr.ParseTree) any
Visit dispatches a parse tree node to the matching visit method and returns false once an error is recorded.
func (*JSONQueryVisitorImpl) VisitAttrPath ¶
func (j *JSONQueryVisitorImpl) VisitAttrPath(ctx *AttrPathContext) any
VisitAttrPath resolves an attribute path against the item and records the left operand.
func (*JSONQueryVisitorImpl) VisitBoolean ¶
func (j *JSONQueryVisitorImpl) VisitBoolean(ctx *BooleanContext) any
VisitBoolean records a boolean literal as the right operand.
func (*JSONQueryVisitorImpl) VisitCompareExp ¶
func (j *JSONQueryVisitorImpl) VisitCompareExp(ctx *CompareExpContext) any
VisitCompareExp evaluates a comparison between an attribute path and a value.
func (*JSONQueryVisitorImpl) VisitDouble ¶
func (j *JSONQueryVisitorImpl) VisitDouble(ctx *DoubleContext) any
VisitDouble records a floating-point literal as the right operand.
func (*JSONQueryVisitorImpl) VisitListDoubles ¶
func (j *JSONQueryVisitorImpl) VisitListDoubles(ctx *ListDoublesContext) any
VisitListDoubles visits the floating-point list of a query.
func (*JSONQueryVisitorImpl) VisitListInts ¶
func (j *JSONQueryVisitorImpl) VisitListInts(ctx *ListIntsContext) any
VisitListInts visits the integer list of a query.
func (*JSONQueryVisitorImpl) VisitListOfDoubles ¶
func (j *JSONQueryVisitorImpl) VisitListOfDoubles(ctx *ListOfDoublesContext) any
VisitListOfDoubles records a list of floating-point numbers as the right operand.
func (*JSONQueryVisitorImpl) VisitListOfInts ¶
func (j *JSONQueryVisitorImpl) VisitListOfInts(ctx *ListOfIntsContext) any
VisitListOfInts records a list of integers as the right operand.
func (*JSONQueryVisitorImpl) VisitListOfStrings ¶
func (j *JSONQueryVisitorImpl) VisitListOfStrings(ctx *ListOfStringsContext) any
VisitListOfStrings records a list of strings as the right operand.
func (*JSONQueryVisitorImpl) VisitListStrings ¶
func (j *JSONQueryVisitorImpl) VisitListStrings(ctx *ListStringsContext) any
VisitListStrings visits the string list of a query.
func (*JSONQueryVisitorImpl) VisitLogicalExp ¶
func (j *JSONQueryVisitorImpl) VisitLogicalExp(ctx *LogicalExpContext) any
VisitLogicalExp evaluates an and/or expression of two queries.
func (*JSONQueryVisitorImpl) VisitLong ¶
func (j *JSONQueryVisitorImpl) VisitLong(ctx *LongContext) any
VisitLong records an integer literal as the right operand.
func (*JSONQueryVisitorImpl) VisitNull ¶
func (j *JSONQueryVisitorImpl) VisitNull(_ *NullContext) any
VisitNull records a null literal as the right operand.
func (*JSONQueryVisitorImpl) VisitParenExp ¶
func (j *JSONQueryVisitorImpl) VisitParenExp(ctx *ParenExpContext) any
VisitParenExp evaluates a parenthesized query and negates it when NOT is present.
func (*JSONQueryVisitorImpl) VisitPresentExp ¶
func (j *JSONQueryVisitorImpl) VisitPresentExp(ctx *PresentExpContext) any
VisitPresentExp reports whether the attribute path resolves to a value.
func (*JSONQueryVisitorImpl) VisitString ¶
func (j *JSONQueryVisitorImpl) VisitString(ctx *StringContext) any
VisitString records a string literal as the right operand.
func (*JSONQueryVisitorImpl) VisitSubAttr ¶
func (j *JSONQueryVisitorImpl) VisitSubAttr(ctx *SubAttrContext) any
VisitSubAttr resolves a nested attribute path.
func (*JSONQueryVisitorImpl) VisitSubListOfDoubles ¶
func (j *JSONQueryVisitorImpl) VisitSubListOfDoubles(ctx *SubListOfDoublesContext) any
VisitSubListOfDoubles appends one floating-point number to the right operand list.
func (*JSONQueryVisitorImpl) VisitSubListOfInts ¶
func (j *JSONQueryVisitorImpl) VisitSubListOfInts(ctx *SubListOfIntsContext) any
VisitSubListOfInts appends one integer to the right operand list.
func (*JSONQueryVisitorImpl) VisitSubListOfStrings ¶
func (j *JSONQueryVisitorImpl) VisitSubListOfStrings(ctx *SubListOfStringsContext) any
VisitSubListOfStrings appends one string to the right operand list.
func (*JSONQueryVisitorImpl) VisitVersion ¶
func (j *JSONQueryVisitorImpl) VisitVersion(ctx *VersionContext) any
VisitVersion records a version literal as the right operand.
type JsonQueryLexer ¶
func NewJsonQueryLexer ¶
func NewJsonQueryLexer(input antlr.CharStream) *JsonQueryLexer
NewJsonQueryLexer produces a new lexer instance for the optional input antlr.CharStream.
type JsonQueryParser ¶
type JsonQueryParser struct {
*antlr.BaseParser
}
func NewJsonQueryParser ¶
func NewJsonQueryParser(input antlr.TokenStream) *JsonQueryParser
NewJsonQueryParser produces a new parser instance for the optional input antlr.TokenStream.
func (*JsonQueryParser) AttrPath ¶
func (p *JsonQueryParser) AttrPath() (localctx IAttrPathContext)
func (*JsonQueryParser) ListDoubles ¶
func (p *JsonQueryParser) ListDoubles() (localctx IListDoublesContext)
func (*JsonQueryParser) ListInts ¶
func (p *JsonQueryParser) ListInts() (localctx IListIntsContext)
func (*JsonQueryParser) ListStrings ¶
func (p *JsonQueryParser) ListStrings() (localctx IListStringsContext)
func (*JsonQueryParser) Query ¶
func (p *JsonQueryParser) Query() (localctx IQueryContext)
func (*JsonQueryParser) Query_Sempred ¶
func (p *JsonQueryParser) Query_Sempred(localctx antlr.RuleContext, predIndex int) bool
func (*JsonQueryParser) Sempred ¶
func (p *JsonQueryParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool
func (*JsonQueryParser) SubAttr ¶
func (p *JsonQueryParser) SubAttr() (localctx ISubAttrContext)
func (*JsonQueryParser) SubListOfDoubles ¶
func (p *JsonQueryParser) SubListOfDoubles() (localctx ISubListOfDoublesContext)
func (*JsonQueryParser) SubListOfInts ¶
func (p *JsonQueryParser) SubListOfInts() (localctx ISubListOfIntsContext)
func (*JsonQueryParser) SubListOfStrings ¶
func (p *JsonQueryParser) SubListOfStrings() (localctx ISubListOfStringsContext)
func (*JsonQueryParser) Value ¶
func (p *JsonQueryParser) Value() (localctx IValueContext)
type JsonQueryVisitor ¶
type JsonQueryVisitor interface {
antlr.ParseTreeVisitor
// Visit a parse tree produced by JsonQueryParser#compareExp.
VisitCompareExp(ctx *CompareExpContext) interface{}
// Visit a parse tree produced by JsonQueryParser#parenExp.
VisitParenExp(ctx *ParenExpContext) interface{}
// Visit a parse tree produced by JsonQueryParser#presentExp.
VisitPresentExp(ctx *PresentExpContext) interface{}
// Visit a parse tree produced by JsonQueryParser#logicalExp.
VisitLogicalExp(ctx *LogicalExpContext) interface{}
// Visit a parse tree produced by JsonQueryParser#attrPath.
VisitAttrPath(ctx *AttrPathContext) interface{}
// Visit a parse tree produced by JsonQueryParser#subAttr.
VisitSubAttr(ctx *SubAttrContext) interface{}
// Visit a parse tree produced by JsonQueryParser#boolean.
VisitBoolean(ctx *BooleanContext) interface{}
// Visit a parse tree produced by JsonQueryParser#null.
VisitNull(ctx *NullContext) interface{}
// Visit a parse tree produced by JsonQueryParser#version.
VisitVersion(ctx *VersionContext) interface{}
// Visit a parse tree produced by JsonQueryParser#string.
VisitString(ctx *StringContext) interface{}
// Visit a parse tree produced by JsonQueryParser#double.
VisitDouble(ctx *DoubleContext) interface{}
// Visit a parse tree produced by JsonQueryParser#long.
VisitLong(ctx *LongContext) interface{}
// Visit a parse tree produced by JsonQueryParser#listOfInts.
VisitListOfInts(ctx *ListOfIntsContext) interface{}
// Visit a parse tree produced by JsonQueryParser#listOfDoubles.
VisitListOfDoubles(ctx *ListOfDoublesContext) interface{}
// Visit a parse tree produced by JsonQueryParser#listOfStrings.
VisitListOfStrings(ctx *ListOfStringsContext) interface{}
// Visit a parse tree produced by JsonQueryParser#listStrings.
VisitListStrings(ctx *ListStringsContext) interface{}
// Visit a parse tree produced by JsonQueryParser#subListOfStrings.
VisitSubListOfStrings(ctx *SubListOfStringsContext) interface{}
// Visit a parse tree produced by JsonQueryParser#listDoubles.
VisitListDoubles(ctx *ListDoublesContext) interface{}
// Visit a parse tree produced by JsonQueryParser#subListOfDoubles.
VisitSubListOfDoubles(ctx *SubListOfDoublesContext) interface{}
// Visit a parse tree produced by JsonQueryParser#listInts.
VisitListInts(ctx *ListIntsContext) interface{}
// Visit a parse tree produced by JsonQueryParser#subListOfInts.
VisitSubListOfInts(ctx *SubListOfIntsContext) interface{}
}
A complete Visitor for a parse tree produced by JsonQueryParser.
type ListDoublesContext ¶
type ListDoublesContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptyListDoublesContext ¶
func NewEmptyListDoublesContext() *ListDoublesContext
func NewListDoublesContext ¶
func NewListDoublesContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ListDoublesContext
func (*ListDoublesContext) Accept ¶
func (s *ListDoublesContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*ListDoublesContext) GetParser ¶
func (s *ListDoublesContext) GetParser() antlr.Parser
func (*ListDoublesContext) GetRuleContext ¶
func (s *ListDoublesContext) GetRuleContext() antlr.RuleContext
func (*ListDoublesContext) IsListDoublesContext ¶
func (*ListDoublesContext) IsListDoublesContext()
func (*ListDoublesContext) SubListOfDoubles ¶
func (s *ListDoublesContext) SubListOfDoubles() ISubListOfDoublesContext
func (*ListDoublesContext) ToStringTree ¶
func (s *ListDoublesContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type ListIntsContext ¶
type ListIntsContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptyListIntsContext ¶
func NewEmptyListIntsContext() *ListIntsContext
func NewListIntsContext ¶
func NewListIntsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ListIntsContext
func (*ListIntsContext) Accept ¶
func (s *ListIntsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*ListIntsContext) GetParser ¶
func (s *ListIntsContext) GetParser() antlr.Parser
func (*ListIntsContext) GetRuleContext ¶
func (s *ListIntsContext) GetRuleContext() antlr.RuleContext
func (*ListIntsContext) IsListIntsContext ¶
func (*ListIntsContext) IsListIntsContext()
func (*ListIntsContext) SubListOfInts ¶
func (s *ListIntsContext) SubListOfInts() ISubListOfIntsContext
func (*ListIntsContext) ToStringTree ¶
func (s *ListIntsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type ListOfDoublesContext ¶
type ListOfDoublesContext struct {
ValueContext
}
func NewListOfDoublesContext ¶
func NewListOfDoublesContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ListOfDoublesContext
func (*ListOfDoublesContext) Accept ¶
func (s *ListOfDoublesContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*ListOfDoublesContext) GetRuleContext ¶
func (s *ListOfDoublesContext) GetRuleContext() antlr.RuleContext
func (*ListOfDoublesContext) ListDoubles ¶
func (s *ListOfDoublesContext) ListDoubles() IListDoublesContext
type ListOfIntsContext ¶
type ListOfIntsContext struct {
ValueContext
}
func NewListOfIntsContext ¶
func NewListOfIntsContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ListOfIntsContext
func (*ListOfIntsContext) Accept ¶
func (s *ListOfIntsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*ListOfIntsContext) GetRuleContext ¶
func (s *ListOfIntsContext) GetRuleContext() antlr.RuleContext
func (*ListOfIntsContext) ListInts ¶
func (s *ListOfIntsContext) ListInts() IListIntsContext
type ListOfStringsContext ¶
type ListOfStringsContext struct {
ValueContext
}
func NewListOfStringsContext ¶
func NewListOfStringsContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ListOfStringsContext
func (*ListOfStringsContext) Accept ¶
func (s *ListOfStringsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*ListOfStringsContext) GetRuleContext ¶
func (s *ListOfStringsContext) GetRuleContext() antlr.RuleContext
func (*ListOfStringsContext) ListStrings ¶
func (s *ListOfStringsContext) ListStrings() IListStringsContext
type ListStringsContext ¶
type ListStringsContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptyListStringsContext ¶
func NewEmptyListStringsContext() *ListStringsContext
func NewListStringsContext ¶
func NewListStringsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ListStringsContext
func (*ListStringsContext) Accept ¶
func (s *ListStringsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*ListStringsContext) GetParser ¶
func (s *ListStringsContext) GetParser() antlr.Parser
func (*ListStringsContext) GetRuleContext ¶
func (s *ListStringsContext) GetRuleContext() antlr.RuleContext
func (*ListStringsContext) IsListStringsContext ¶
func (*ListStringsContext) IsListStringsContext()
func (*ListStringsContext) SubListOfStrings ¶
func (s *ListStringsContext) SubListOfStrings() ISubListOfStringsContext
func (*ListStringsContext) ToStringTree ¶
func (s *ListStringsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type LogicalExpContext ¶
type LogicalExpContext struct {
QueryContext
}
func NewLogicalExpContext ¶
func NewLogicalExpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *LogicalExpContext
func (*LogicalExpContext) Accept ¶
func (s *LogicalExpContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*LogicalExpContext) AllQuery ¶
func (s *LogicalExpContext) AllQuery() []IQueryContext
func (*LogicalExpContext) AllSP ¶
func (s *LogicalExpContext) AllSP() []antlr.TerminalNode
func (*LogicalExpContext) GetRuleContext ¶
func (s *LogicalExpContext) GetRuleContext() antlr.RuleContext
func (*LogicalExpContext) LOGICAL_OPERATOR ¶
func (s *LogicalExpContext) LOGICAL_OPERATOR() antlr.TerminalNode
func (*LogicalExpContext) Query ¶
func (s *LogicalExpContext) Query(i int) IQueryContext
func (*LogicalExpContext) SP ¶
func (s *LogicalExpContext) SP(i int) antlr.TerminalNode
type LongContext ¶
type LongContext struct {
ValueContext
}
func NewLongContext ¶
func NewLongContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *LongContext
func (*LongContext) Accept ¶
func (s *LongContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*LongContext) EXP ¶
func (s *LongContext) EXP() antlr.TerminalNode
func (*LongContext) GetRuleContext ¶
func (s *LongContext) GetRuleContext() antlr.RuleContext
func (*LongContext) INT ¶
func (s *LongContext) INT() antlr.TerminalNode
type Match ¶ added in v0.2.0
type Match uint8
Match is the three-valued result of a rule with segment terms.
func (Match) Not ¶ added in v0.2.0
Not is the three-valued negation: an unknown result stays unknown.
func (Match) String ¶ added in v0.2.0
String implements fmt.Stringer.
type NestedError ¶
NestedError wraps an error with a message and the values that describe it.
func (*NestedError) Error ¶
func (e *NestedError) Error() string
Error renders Vals plus "err" and "msg" as JSON. It marshals a copy so e is never written to and concurrent Error calls are safe.
func (*NestedError) Original ¶
func (e *NestedError) Original() error
Original returns the innermost error of a chain of NestedError values.
func (*NestedError) Set ¶
func (e *NestedError) Set(vals ErrVals) *NestedError
Set merges vals into the values of the error and returns the error.
type NullContext ¶
type NullContext struct {
ValueContext
}
func NewNullContext ¶
func NewNullContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *NullContext
func (*NullContext) Accept ¶
func (s *NullContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*NullContext) GetRuleContext ¶
func (s *NullContext) GetRuleContext() antlr.RuleContext
func (*NullContext) NULL ¶
func (s *NullContext) NULL() antlr.TerminalNode
type NullOperation ¶
type NullOperation struct {
}
NullOperation compares operands that may be null.
func (*NullOperation) CO ¶
func (*NullOperation) CO(_, _ Operand) (bool, error)
CO always returns ErrInvalidOperation because null operands cannot be searched.
func (*NullOperation) EQ ¶
func (*NullOperation) EQ(left, _ Operand) (bool, error)
EQ reports whether the left operand is nil.
func (*NullOperation) EW ¶
func (*NullOperation) EW(_, _ Operand) (bool, error)
EW always returns ErrInvalidOperation because null operands cannot be searched.
func (*NullOperation) GE ¶
func (*NullOperation) GE(_, _ Operand) (bool, error)
GE always returns ErrInvalidOperation because null operands cannot be ordered.
func (*NullOperation) GT ¶
func (*NullOperation) GT(_, _ Operand) (bool, error)
GT always returns ErrInvalidOperation because null operands cannot be ordered.
func (*NullOperation) IN ¶
func (*NullOperation) IN(_, _ Operand) (bool, error)
IN always returns ErrInvalidOperation because null operands cannot be searched.
func (*NullOperation) LE ¶
func (*NullOperation) LE(_, _ Operand) (bool, error)
LE always returns ErrInvalidOperation because null operands cannot be ordered.
func (*NullOperation) LT ¶
func (*NullOperation) LT(_, _ Operand) (bool, error)
LT always returns ErrInvalidOperation because null operands cannot be ordered.
type Operand ¶
type Operand any
Operand is a value that an operation compares, such as a string, number or boolean.
type Operation ¶
type Operation interface {
EQ(left Operand, right Operand) (bool, error)
NE(left Operand, right Operand) (bool, error)
GT(left Operand, right Operand) (bool, error)
LT(left Operand, right Operand) (bool, error)
GE(left Operand, right Operand) (bool, error)
LE(left Operand, right Operand) (bool, error)
CO(left Operand, right Operand) (bool, error)
SW(left Operand, right Operand) (bool, error)
EW(left Operand, right Operand) (bool, error)
IN(left Operand, right Operand) (bool, error)
}
Operation compares two operands with the query operators.
type ParenExpContext ¶
type ParenExpContext struct {
QueryContext
}
func NewParenExpContext ¶
func NewParenExpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *ParenExpContext
func (*ParenExpContext) Accept ¶
func (s *ParenExpContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*ParenExpContext) AllSP ¶
func (s *ParenExpContext) AllSP() []antlr.TerminalNode
func (*ParenExpContext) GetRuleContext ¶
func (s *ParenExpContext) GetRuleContext() antlr.RuleContext
func (*ParenExpContext) NOT ¶
func (s *ParenExpContext) NOT() antlr.TerminalNode
func (*ParenExpContext) Query ¶
func (s *ParenExpContext) Query() IQueryContext
func (*ParenExpContext) SP ¶
func (s *ParenExpContext) SP(i int) antlr.TerminalNode
type PresentExpContext ¶
type PresentExpContext struct {
QueryContext
}
func NewPresentExpContext ¶
func NewPresentExpContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *PresentExpContext
func (*PresentExpContext) Accept ¶
func (s *PresentExpContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*PresentExpContext) AttrPath ¶
func (s *PresentExpContext) AttrPath() IAttrPathContext
func (*PresentExpContext) GetRuleContext ¶
func (s *PresentExpContext) GetRuleContext() antlr.RuleContext
func (*PresentExpContext) SP ¶
func (s *PresentExpContext) SP() antlr.TerminalNode
type QueryContext ¶
type QueryContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptyQueryContext ¶
func NewEmptyQueryContext() *QueryContext
func NewQueryContext ¶
func NewQueryContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *QueryContext
func (*QueryContext) CopyAll ¶
func (s *QueryContext) CopyAll(ctx *QueryContext)
func (*QueryContext) GetParser ¶
func (s *QueryContext) GetParser() antlr.Parser
func (*QueryContext) GetRuleContext ¶
func (s *QueryContext) GetRuleContext() antlr.RuleContext
func (*QueryContext) IsQueryContext ¶
func (*QueryContext) IsQueryContext()
func (*QueryContext) ToStringTree ¶
func (s *QueryContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type SegmentError ¶ added in v0.2.0
type SegmentError struct {
// Reason says what is wrong, in a sentence.
Reason string
// Offset is the byte offset in the rule of the problem.
Offset int
}
SegmentError is the error of a segment() term that is not valid. It wraps ErrSegmentSyntax.
func (*SegmentError) Error ¶ added in v0.2.0
func (e *SegmentError) Error() string
Error implements error.
func (*SegmentError) Unwrap ¶ added in v0.2.0
func (*SegmentError) Unwrap() error
Unwrap returns ErrSegmentSyntax.
type SegmentState ¶ added in v0.2.0
type SegmentState uint8
SegmentState is what is known of the membership of an attribute value in a segment. The zero value is SegmentUnknown, so a new vector reads as "nothing is known".
const ( // SegmentUnknown means the membership could not be determined (store down, timeout, no provider). SegmentUnknown SegmentState = iota // SegmentNotMember means the value is not in the segment. SegmentNotMember // SegmentMember means the value is in the segment. SegmentMember )
func (SegmentState) Match ¶ added in v0.2.0
func (s SegmentState) Match() Match
Match is the result of a term whose membership is the state.
func (SegmentState) String ¶ added in v0.2.0
func (s SegmentState) String() string
String implements fmt.Stringer.
type SegmentTerm ¶ added in v0.2.0
type SegmentTerm struct {
// Name is the segment.
Name string
// Path is the attribute, one element for each level of a nested attribute ("user.email" is {"user", "email"}).
Path []string
}
SegmentTerm is a segment term of a rule: the attribute whose value is looked up, in the segment Name. Two equal terms of a rule are one term.
type StringContext ¶
type StringContext struct {
ValueContext
}
func NewStringContext ¶
func NewStringContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *StringContext
func (*StringContext) Accept ¶
func (s *StringContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*StringContext) GetRuleContext ¶
func (s *StringContext) GetRuleContext() antlr.RuleContext
func (*StringContext) STRING ¶
func (s *StringContext) STRING() antlr.TerminalNode
type StringOperation ¶
type StringOperation struct {
NullOperation
}
StringOperation compares string operands.
func (*StringOperation) CO ¶
func (o *StringOperation) CO(left, right Operand) (bool, error)
CO reports whether the left string operand contains the right one.
func (*StringOperation) EQ ¶
func (o *StringOperation) EQ(left, right Operand) (bool, error)
EQ reports whether two string operands are equal.
func (*StringOperation) EW ¶
func (o *StringOperation) EW(left, right Operand) (bool, error)
EW reports whether the left string operand ends with the right one.
func (*StringOperation) GE ¶
func (o *StringOperation) GE(left, right Operand) (bool, error)
GE reports whether the left string operand sorts at or after the right one.
func (*StringOperation) GT ¶
func (o *StringOperation) GT(left, right Operand) (bool, error)
GT reports whether the left string operand sorts after the right one.
func (*StringOperation) IN ¶
func (o *StringOperation) IN(left, right Operand) (bool, error)
IN reports whether the left string operand is one of the values in the right operand.
func (*StringOperation) LE ¶
func (o *StringOperation) LE(left, right Operand) (bool, error)
LE reports whether the left string operand sorts at or before the right one.
func (*StringOperation) LT ¶
func (o *StringOperation) LT(left, right Operand) (bool, error)
LT reports whether the left string operand sorts before the right one.
type SubAttrContext ¶
type SubAttrContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptySubAttrContext ¶
func NewEmptySubAttrContext() *SubAttrContext
func NewSubAttrContext ¶
func NewSubAttrContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SubAttrContext
func (*SubAttrContext) Accept ¶
func (s *SubAttrContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*SubAttrContext) AttrPath ¶
func (s *SubAttrContext) AttrPath() IAttrPathContext
func (*SubAttrContext) GetParser ¶
func (s *SubAttrContext) GetParser() antlr.Parser
func (*SubAttrContext) GetRuleContext ¶
func (s *SubAttrContext) GetRuleContext() antlr.RuleContext
func (*SubAttrContext) IsSubAttrContext ¶
func (*SubAttrContext) IsSubAttrContext()
func (*SubAttrContext) ToStringTree ¶
func (s *SubAttrContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type SubListOfDoublesContext ¶
type SubListOfDoublesContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptySubListOfDoublesContext ¶
func NewEmptySubListOfDoublesContext() *SubListOfDoublesContext
func NewSubListOfDoublesContext ¶
func NewSubListOfDoublesContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SubListOfDoublesContext
func (*SubListOfDoublesContext) Accept ¶
func (s *SubListOfDoublesContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*SubListOfDoublesContext) COMMA ¶
func (s *SubListOfDoublesContext) COMMA() antlr.TerminalNode
func (*SubListOfDoublesContext) DOUBLE ¶
func (s *SubListOfDoublesContext) DOUBLE() antlr.TerminalNode
func (*SubListOfDoublesContext) GetParser ¶
func (s *SubListOfDoublesContext) GetParser() antlr.Parser
func (*SubListOfDoublesContext) GetRuleContext ¶
func (s *SubListOfDoublesContext) GetRuleContext() antlr.RuleContext
func (*SubListOfDoublesContext) IsSubListOfDoublesContext ¶
func (*SubListOfDoublesContext) IsSubListOfDoublesContext()
func (*SubListOfDoublesContext) SubListOfDoubles ¶
func (s *SubListOfDoublesContext) SubListOfDoubles() ISubListOfDoublesContext
func (*SubListOfDoublesContext) ToStringTree ¶
func (s *SubListOfDoublesContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type SubListOfIntsContext ¶
type SubListOfIntsContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptySubListOfIntsContext ¶
func NewEmptySubListOfIntsContext() *SubListOfIntsContext
func NewSubListOfIntsContext ¶
func NewSubListOfIntsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SubListOfIntsContext
func (*SubListOfIntsContext) Accept ¶
func (s *SubListOfIntsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*SubListOfIntsContext) COMMA ¶
func (s *SubListOfIntsContext) COMMA() antlr.TerminalNode
func (*SubListOfIntsContext) GetParser ¶
func (s *SubListOfIntsContext) GetParser() antlr.Parser
func (*SubListOfIntsContext) GetRuleContext ¶
func (s *SubListOfIntsContext) GetRuleContext() antlr.RuleContext
func (*SubListOfIntsContext) INT ¶
func (s *SubListOfIntsContext) INT() antlr.TerminalNode
func (*SubListOfIntsContext) IsSubListOfIntsContext ¶
func (*SubListOfIntsContext) IsSubListOfIntsContext()
func (*SubListOfIntsContext) SubListOfInts ¶
func (s *SubListOfIntsContext) SubListOfInts() ISubListOfIntsContext
func (*SubListOfIntsContext) ToStringTree ¶
func (s *SubListOfIntsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type SubListOfStringsContext ¶
type SubListOfStringsContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptySubListOfStringsContext ¶
func NewEmptySubListOfStringsContext() *SubListOfStringsContext
func NewSubListOfStringsContext ¶
func NewSubListOfStringsContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SubListOfStringsContext
func (*SubListOfStringsContext) Accept ¶
func (s *SubListOfStringsContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*SubListOfStringsContext) COMMA ¶
func (s *SubListOfStringsContext) COMMA() antlr.TerminalNode
func (*SubListOfStringsContext) GetParser ¶
func (s *SubListOfStringsContext) GetParser() antlr.Parser
func (*SubListOfStringsContext) GetRuleContext ¶
func (s *SubListOfStringsContext) GetRuleContext() antlr.RuleContext
func (*SubListOfStringsContext) IsSubListOfStringsContext ¶
func (*SubListOfStringsContext) IsSubListOfStringsContext()
func (*SubListOfStringsContext) STRING ¶
func (s *SubListOfStringsContext) STRING() antlr.TerminalNode
func (*SubListOfStringsContext) SubListOfStrings ¶
func (s *SubListOfStringsContext) SubListOfStrings() ISubListOfStringsContext
func (*SubListOfStringsContext) ToStringTree ¶
func (s *SubListOfStringsContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type ValueContext ¶
type ValueContext struct {
antlr.BaseParserRuleContext
// contains filtered or unexported fields
}
func NewEmptyValueContext ¶
func NewEmptyValueContext() *ValueContext
func NewValueContext ¶
func NewValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ValueContext
func (*ValueContext) CopyAll ¶
func (s *ValueContext) CopyAll(ctx *ValueContext)
func (*ValueContext) GetParser ¶
func (s *ValueContext) GetParser() antlr.Parser
func (*ValueContext) GetRuleContext ¶
func (s *ValueContext) GetRuleContext() antlr.RuleContext
func (*ValueContext) IsValueContext ¶
func (*ValueContext) IsValueContext()
func (*ValueContext) ToStringTree ¶
func (s *ValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string
type VersionContext ¶
type VersionContext struct {
ValueContext
}
func NewVersionContext ¶
func NewVersionContext(parser antlr.Parser, ctx antlr.ParserRuleContext) *VersionContext
func (*VersionContext) Accept ¶
func (s *VersionContext) Accept(visitor antlr.ParseTreeVisitor) interface{}
func (*VersionContext) GetRuleContext ¶
func (s *VersionContext) GetRuleContext() antlr.RuleContext
func (*VersionContext) VERSION ¶
func (s *VersionContext) VERSION() antlr.TerminalNode
type VersionOperation ¶
type VersionOperation struct {
NullOperation
}
VersionOperation compares semantic version operands.
func (*VersionOperation) EQ ¶
func (v *VersionOperation) EQ(left, right Operand) (bool, error)
EQ reports whether two versions are equal.
func (*VersionOperation) GE ¶
func (v *VersionOperation) GE(left, right Operand) (bool, error)
GE reports whether the left version is higher than or equal to the right one.
func (*VersionOperation) GT ¶
func (v *VersionOperation) GT(left, right Operand) (bool, error)
GT reports whether the left version is higher than the right one.
func (*VersionOperation) LE ¶
func (v *VersionOperation) LE(left, right Operand) (bool, error)
LE reports whether the left version is lower than or equal to the right one.