Documentation
¶
Index ¶
- func GetValidConnectors() []string
- func GetValidSubjects() []string
- func NewConnectorTrie() *trie.Trie
- func NewTagTrie(tags []string) *trie.Trie
- type AutocompleteError
- type AutocompleteErrorCode
- type CompletionEngine
- type DType
- type EngineState
- type ErrEndOfInput
- type ErrInvalidLexeme
- type ErrInvalidSubject
- type ErrInvalidToken
- type Lexeme
- type Lexer
- type MegaTrie
- type Operator
- type Parser
- func (p *Parser) AndExpr() (QueryExpr, error)
- func (p *Parser) Expression() (QueryExpr, error)
- func (p *Parser) FunctionCall() (QueryExpr, error)
- func (p *Parser) NotExpr() (QueryExpr, error)
- func (p *Parser) OrExpr() (QueryExpr, error)
- func (p *Parser) Parse() (QueryExpr, error)
- func (p *Parser) Query() (QueryExpr, error)
- func (p *Parser) Subject() (string, error)
- func (p *Parser) Term() (QueryExpr, error)
- func (p *Parser) ValueAnd() (ValueExpr, error)
- func (p *Parser) ValueExpr() (ValueExpr, error)
- func (p *Parser) ValueNot() (ValueExpr, error)
- func (p *Parser) ValueObject() (ValueExpr, error)
- func (p *Parser) ValueOr() (ValueExpr, error)
- func (p *Parser) ValueTerm() (ValueExpr, error)
- func (p *Parser) Verb(subject string) (string, error)
- type ParserError
- type QueryBinaryOp
- type QueryCondition
- type QueryExpr
- type QueryUnaryOp
- type Scanner
- type ScannerError
- type Subject
- type Token
- type TokenType
- type Value
- type ValueBinaryOp
- type ValueExpr
- type ValueUnaryOp
- type Verb
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetValidConnectors ¶
func GetValidConnectors() []string
func GetValidSubjects ¶
func GetValidSubjects() []string
func NewConnectorTrie ¶
func NewTagTrie ¶
Types ¶
type AutocompleteError ¶
type AutocompleteError struct {
Code AutocompleteErrorCode
Position int
Message string
}
func NewAutocompleteError ¶
func NewAutocompleteError(code AutocompleteErrorCode, pos int, msg string) *AutocompleteError
func (*AutocompleteError) Error ¶
func (e *AutocompleteError) Error() string
type AutocompleteErrorCode ¶
type AutocompleteErrorCode int
const (
InvalidCharacter AutocompleteErrorCode = iota
)
type CompletionEngine ¶
type CompletionEngine struct {
// contains filtered or unexported fields
}
CompletionEngine is a trie-based autocompletion engine for NTQL
func NewCompletionEngine ¶ added in v0.1.4
func NewCompletionEngine(tags []string) *CompletionEngine
func (*CompletionEngine) SuggestSubject ¶
func (e *CompletionEngine) SuggestSubject(s string) ([]string, error)
type DType ¶
type DType int
Data types for any objects passed as an argument to a function in the NTQL query
type EngineState ¶
type EngineState int
type ErrEndOfInput ¶
type ErrEndOfInput struct{}
func (ErrEndOfInput) Error ¶
func (e ErrEndOfInput) Error() string
type ErrInvalidLexeme ¶
type ErrInvalidLexeme struct {
Input byte
}
func (ErrInvalidLexeme) Error ¶
func (e ErrInvalidLexeme) Error() string
type ErrInvalidSubject ¶
func (ErrInvalidSubject) Error ¶
func (e ErrInvalidSubject) Error() string
type ErrInvalidToken ¶
func (ErrInvalidToken) Error ¶
func (e ErrInvalidToken) Error() string
type Lexer ¶
type Lexer struct {
Tokens []Token
Scanner *Scanner
InnerDepth int
ExpectedTokens []TokenType
ExpectedDataTypes []DType
// contains filtered or unexported fields
}
func (*Lexer) GetPosition ¶
func (*Lexer) LastLexeme ¶
type MegaTrie ¶
type MegaTrie struct {
// contains filtered or unexported fields
}
func NewMegaTrie ¶
func NewMegaTrie() *MegaTrie
type Operator ¶
type Operator string // I chose string over iota to increase resilience to changes, especially for communication between the frontend and backend
const ( // Binary operators OperatorAnd Operator = "AND" OperatorOr Operator = "OR" OperatorXor Operator = "XOR" // Unary operators OperatorNot Operator = "NOT" // Comparison operators OperatorEq Operator = "equals" OperatorNeq Operator = "notEquals" OperatorGt Operator = "greaterThan" OperatorLT Operator = "lessThan" OperatorGte Operator = "greaterThanOrEquals" OperatorLte Operator = "lessThanOrEquals" // String operators OperatorCnt Operator = "contains" OperatorSW Operator = "startsWith" OperatorEw Operator = "endsWith" )
func NewOperator ¶
type Parser ¶
TODO: Sanitize input BNF Grammar: query = expr expr = or_expr or_expr = and_expr ("OR" and_expr)* and_expr = not_expr ("AND" not_expr)* not_expr = ["!"] term term = func_call | "(" expr ")" func_call = subject "." verb "(" value_expr ")" # subject from list of subjects, verb from subject verbs value_expr = value_or value_or = value_and ("OR" value_and)* value_and = value_not ("AND" value_not)* value_not = ["!"] value_term value_term = "(" value_expr ")" | value value = object # type belonging to current verb object = NUMBER | STRING | DATE | TAG
func (*Parser) Expression ¶
func (*Parser) FunctionCall ¶
func (*Parser) ValueObject ¶
type ParserError ¶
func NewParserError ¶
func NewParserError(message string, t Token) *ParserError
func (*ParserError) Error ¶
func (e *ParserError) Error() string
type QueryBinaryOp ¶
type QueryBinaryOp struct {
Left QueryExpr `json:"left"`
Right QueryExpr `json:"right"`
Operator Operator `json:"op"`
}
QueryBinaryOp represents a binary operation in a query.
func NewQueryAnd ¶
func NewQueryAnd(left QueryExpr, right QueryExpr) *QueryBinaryOp
func NewQueryOr ¶
func NewQueryOr(left QueryExpr, right QueryExpr) *QueryBinaryOp
func (*QueryBinaryOp) String ¶
func (q *QueryBinaryOp) String() string
func (*QueryBinaryOp) ToSQL ¶
func (q *QueryBinaryOp) ToSQL() (string, error)
type QueryCondition ¶
type QueryCondition struct {
Field string `json:"field"`
Operator Operator `json:"operator"`
Value string `json:"value"`
}
QueryCondition represents a condition in a query.
func NewQueryCondition ¶
func NewQueryCondition(subject string, verb string, value string) (*QueryCondition, error)
func (*QueryCondition) String ¶
func (q *QueryCondition) String() string
func (*QueryCondition) ToSQL ¶
func (c *QueryCondition) ToSQL() (string, error)
TODO: Input sanitization Convert the query condition to a SQL string.
type QueryExpr ¶
type QueryExpr interface {
// ToSQL converts the query expression to a SQL string.
ToSQL() (string, error)
String() string
}
func BuildQueryExprFromMap ¶
type QueryUnaryOp ¶
QueryUnaryOp represents a unary operation in a query.
func NewQueryNot ¶
func NewQueryNot(expr QueryExpr) *QueryUnaryOp
func (*QueryUnaryOp) String ¶
func (q *QueryUnaryOp) String() string
func (*QueryUnaryOp) ToSQL ¶
func (q *QueryUnaryOp) ToSQL() (string, error)
type Scanner ¶
func NewScanner ¶
func (*Scanner) GetPosition ¶
func (*Scanner) LastLexeme ¶
func (*Scanner) ScanLexeme ¶
type ScannerError ¶
type ScannerError struct {
Message error
}
func (*ScannerError) Error ¶
func (e *ScannerError) Error() string
type Token ¶
Example: tag.equals(hello OR goodbye) date.before(2024-01-08) AND date.after(2024-01-09)