Documentation
¶
Overview ¶
Package lexer provides a hand-written, zero-copy lexer for RFC 9535 JSONPath expressions.
Tokens store byte offsets (start, end) into the source string rather than copied substrings, enabling zero-allocation access via Token.Val. String tokens additionally store a parsed value with escape sequences resolved.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSyntax = errors.New("jsonpath")
ErrSyntax is the sentinel error returned by Token.Err for invalid tokens.
Functions ¶
This section is empty.
Types ¶
type Kind ¶
type Kind int16
Kind identifies a lexical token type.
const ( Invalid Kind = iota // error token; Value holds error message EOF // end of input Dollar // $ At // @ Dot // . DotDot // .. LeftBracket // [ RightBracket // ] LeftParen // ( RightParen // ) Star // * Question // ? Comma // , Colon // : Equal // == NotEqual // != Less // < LessEqual // <= Greater // > GreaterEqual // >= And // && Or // || Not // ! Ident // identifier (member-name-shorthand / function name) Int // integer literal Number // number (float) literal String // single- or double-quoted string; Value holds parsed content True // true False // false Null // null )
Kind values.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer tokenizes an RFC 9535 JSONPath expression. Create with New and call Lexer.Scan repeatedly to get tokens.
type Token ¶
type Token struct {
Kind Kind // Kind is the token type.
Start int // byte offset in source (inclusive)
End int // byte offset in source (exclusive)
Value string // parsed value for String; error message for Invalid
}
Token represents a single lexical token. Use Token.Val for zero-copy access to the raw source text. For String tokens, Token.Value holds the parsed string with escape sequences resolved.