Documentation ¶
Overview ¶
Package kvalscanner implements a basic lexical scanner for KVAL (Key Value Access Language). The language has been created for more fluid access to Key-Value-like databases such as the popular BoltDb.
Parsers can access a new Scanner() to check that a user provided string is valid according to the language's specification. For Golang, however, this work is already done for you at http://github.com/wayblink/kval-parse
The most up-to-date specification for KVAL can be found here: https://github.com/wayblink/kval
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrorLookup = map[Token]string{ ILLEGAL: "ILLEGAL", EOF: "EOF", WS: "WHITESPACE", LITERAL: "LITERAL", BUCKEY: "BUCKET >>>> KEY", BUCBUC: "BUCKET >> BUCKET", KEYVAL: "KEY :: VALUE", ASSIGN: "ASSIGNMENT", USCORE: "UNDERSCORE", OPATT: "OPEN REGEX PATTERN", CPATT: "CLOSE REGEX PATTERN", INS: "INSERT KEYWORD", GET: "GET KEYWORD", LIS: "LIS KEYWORD", DEL: "DEL KEYWORD", REN: "REN KEYWORD", REGEX: "REGEX PATTERN", }
ErrorLookup map is used to look up an error and provide a human readable response
var KeywordMap = map[string]int{
"INS": 0x1,
"ins": 0x1,
"Ins": 0x1,
"GET": 0x2,
"get": 0x2,
"Get": 0x2,
"LIS": 0x3,
"lis": 0x3,
"Lis": 0x3,
"DEL": 0x4,
"del": 0x4,
"Del": 0x4,
"REN": 0x5,
"ren": 0x5,
"Ren": 0x5,
}
KeywordMap values exported for KVAL Parser to verify keywords Lookup 'LIT' value in KeyWordMap and if found we have a KVAL key word, e.g. INS, GET, LIS, REN, DEL. If used correctly this map will help a parser take care of and case-sensitivity issues when users specify query strings.
Functions ¶
This section is empty.
Types ¶
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner represents a lexical scanner.
func NewScanner ¶
NewScanner returns a new instance of Scanner.
type Token ¶
type Token int
Token represents a lexical token.
const ( ILLEGAL Token = iota // Spacial token, ILLEGAL: Token is an illegal character EOF // Spacial token, EOF: Token signals the end of input WS // Spacial token, WS: Token signals whitespace has been found LITERAL // LITERAL: String literal discovered BUCKEY // Other operator, BUCKKEY: >>>> Bucket to Key syntax for KVAL BUCBUC // Other operator, BUCBUC: >> Bucket to Bucket syntax for KVAL KEYVAL // Other operator, KEYVALL :: Key to Value syntax for KVAL ASSIGN // Other operator, ASSIGN: => Assignment operator for KVAL renames USCORE // Single character operator, USCORE: _ Return unknown Key or Value OPATT // Single character operator, OPATT: { Open a regular expression pattern CPATT // Single character operator, COATT: } Close a regular expression pattern INS // Keyword, INS: Insert capability of KVAL GET // Keyword, GET: Get capability of KVAL LIS // Keyword, LIS: LIS capability of KVAL DEL // Keyword, DEL: Delete capability of KVAL REN // Keyword, REN: Rename capability of KVAL REGEX // Regular expression, REGEX: {PATT} ANy regex pattern inside OPATT and CPATT )
Tokens to scan for that satisfy the KVAL (Key Value Access Language) specification