Documentation
¶
Index ¶
- Constants
- Variables
- type BetweenExpr
- type ComparisonExpr
- type Evaluator
- type FunctionExpr
- type InExpr
- type Lexer
- type LogicalExpr
- type Node
- type NotExpr
- type Parser
- type PathElement
- type PathElementType
- type PathExpr
- type ProjectionExpr
- type Token
- type TokenType
- type UpdateAction
- type UpdateExpr
- type UpdateItem
- type ValuePlaceholder
Constants ¶
const ( PrecOR int PrecAND PrecNOT PrecComparison PrecArithmetic )
Variables ¶
var ( ErrValuePlaceholderNotFound = errors.New("value placeholder not found") ErrUnsupportedNodeType = errors.New("unsupported node type") ErrSizeExpectsOneArg = errors.New("size() expects 1 argument") ErrAttributeExistsExpectsPath = errors.New("attribute_exists() expects a path") ErrAttributeExistsExpectsOne = errors.New("attribute_exists() expects 1 argument") ErrAttributeNExistsExpectsPath = errors.New("attribute_not_exists() expects a path") ErrAttributeNExistsExpectsOne = errors.New("attribute_not_exists() expects 1 argument") ErrBeginsWithExpectsTwo = errors.New("begins_with() expects 2 arguments") ErrContainsExpectsTwo = errors.New("contains() expects 2 arguments") ErrAttributeTypeExpectsTwo = errors.New("attribute_type() expects 2 arguments") ErrListAppendExpectsTwo = errors.New("list_append() expects 2 arguments") ErrUnknownFunction = errors.New("unknown function") ErrUpdatePathMustBePathExpr = errors.New("update item path must be a PathExpr") ErrExpectedMapForKey = errors.New("expected map for key") ErrExpectedListAtIndex = errors.New("expected list at index") ErrExpectedListForIndex = errors.New("expected list for index") ErrIndexOutOfRange = errors.New("index out of range") ErrExpectedMapForM = errors.New("expected map for M") ErrExpectedListForL = errors.New("expected list for L") ErrUnsupportedArithmeticOp = errors.New("unsupported arithmetic operator") ErrIfNotExistsExpectsTwo = errors.New("if_not_exists() expects 2 arguments") ErrDeleteValueMustBeSet = errors.New("DELETE value must be a set") ErrSSValueMustBeSlice = errors.New("SS value must be []string") ErrCurrentValueMustBeMap = errors.New("current value must be a map") ErrCurrentSSValueMustBeSlice = errors.New("current SS value must be []string") ErrNSValueMustBeSlice = errors.New("NS value must be []string") ErrCurrentNSValueMustBeSlice = errors.New("current NS value must be []string") ErrBSValueMustBeSlice = errors.New("BS value must be [][]byte") ErrCurrentBSValueMustBeSlice = errors.New("current BS value must be [][]byte") ErrSetTypeMismatch = errors.New( "ADD: existing set type does not match the type being added", ) ErrSetSizeOverflow = errors.New("set size overflow") ErrInvalidSizeArg = errors.New( "size() only supports String, Binary, Map, List, and Set types", ) ErrUnsupportedAddType = errors.New( "ADD action is only supported for Number and Set types", ) )
Sentinel errors for evaluator.
var ( ErrExpectedRParen = errors.New("expected ) after function args") ErrExpectedLParen = errors.New("expected ( after function name") ErrExpectedIdentifierDot = errors.New("expected identifier after dot") ErrExpectedRBracket = errors.New("expected ]") ErrExpectedANDInBetween = errors.New("expected AND in BETWEEN") ErrExpectedLParenAfterIN = errors.New("expected ( after IN") ErrExpectedRParenAfterIN = errors.New("expected ) after IN candidates") ErrExpectedEqualInSET = errors.New("expected = in SET") ErrUnexpectedToken = errors.New("unexpected token") ErrUnexpectedOperand = errors.New("unexpected operand token") ErrExpectedIndex = errors.New("expected index") ErrExpectedRParen2 = errors.New("expected )") )
Sentinel errors for parser.
Functions ¶
This section is empty.
Types ¶
type BetweenExpr ¶
type ComparisonExpr ¶
ComparisonExpr represents a comparison expression (=, <>, <, >, <=, >=).
type Evaluator ¶
type Evaluator struct {
Item map[string]any
AttrNames map[string]string
AttrValues map[string]any
// UpdatedPaths tracks the top-level attribute names touched by ApplyUpdate.
UpdatedPaths map[string]struct{}
}
func (*Evaluator) ApplyProjection ¶
func (e *Evaluator) ApplyProjection(p *ProjectionExpr) map[string]any
func (*Evaluator) ApplyUpdate ¶
func (e *Evaluator) ApplyUpdate(u *UpdateExpr) error
type FunctionExpr ¶
FunctionExpr represents a function call expression (e.g., size, attribute_exists).
type LogicalExpr ¶
LogicalExpr represents a logical expression (AND, OR) combining two nodes.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ParseCondition ¶
ParseCondition parses a ConditionExpression.
func (*Parser) ParseProjection ¶
func (p *Parser) ParseProjection() (*ProjectionExpr, error)
ParseProjection parses a ProjectionExpression.
func (*Parser) ParseUpdate ¶
func (p *Parser) ParseUpdate() (*UpdateExpr, error)
ParseUpdate parses an UpdateExpression.
type PathElement ¶
type PathElement struct {
Name string
Index int
Type PathElementType
}
type PathElementType ¶
type PathElementType int
const ( ElementKey PathElementType = iota ElementIndex )
type PathExpr ¶
type PathExpr struct {
Elements []PathElement
}
PathExpr represents a path expression (e.g., a.b[0]).
type ProjectionExpr ¶
type ProjectionExpr struct {
Paths []Node // PathExpr
}
ProjectionExpr represents a projection expression listing the paths to include.
type TokenType ¶
type TokenType int
const ( TokenEOF TokenType = iota TokenError // TokenIdentifier represents identifiers and placeholders. TokenIdentifier // #name or pk or info.tags TokenValue // :val // TokenEqual represents operators. TokenEqual // = TokenNotEqual // <> TokenLess // < TokenGreater // > TokenLessEqual // <= TokenGreaterEqual // >= TokenPlus // + TokenMinus // - TokenLParen // ( TokenRParen // ) TokenComma // , TokenDot // . TokenLBracket // [ TokenRBracket // ] // TokenAND represents keywords. TokenAND TokenOR TokenNOT TokenBETWEEN TokenIN TokenSET TokenREMOVE TokenADD TokenDELETE // TokenSize represents function keywords. TokenSize TokenAttributeExists TokenAttributeNotExists TokenBeginsWith TokenContains TokenAttributeType TokenIfNotExists TokenListAppend )
type UpdateAction ¶
type UpdateAction struct {
Items []UpdateItem
Type TokenType
}
type UpdateExpr ¶
type UpdateExpr struct {
Actions []UpdateAction
}
UpdateExpr represents an update expression with one or more actions (SET, REMOVE, ADD, DELETE).
type UpdateItem ¶
type ValuePlaceholder ¶
type ValuePlaceholder struct {
Name string
}
ValuePlaceholder represents a value placeholder (e.g., :val).