wip bitfield grammar tokens.
@@ -72,6 +72,11 @@ CONST = {
"justid": "JUSTID",
"block": "BLOCK",
"noack": "NOACK",
+ "get": "GET",
+ "set": "SET",
+ "incrby": "INCRBY",
+ "overflow": "OVERFLOW",
+ "overflow_option": "WRAP SAT FAIL"
}
@@ -123,6 +128,7 @@ CURSOR = fr"(?P<cursor>{NUM})"
PARAMETER = fr"(?P<parameter>{VALID_TOKEN})"
DOUBLE_LUA = fr'(?P<double_lua>[^"]*)'
SINGLE_LUA = fr"(?P<single_lua>[^']*)"
+INTTYPE = r"(?P(<inttype>(i|u)\d+))"
# IP re copied from:
# https://www.regular-expressions.info/ip.html
IP = r"""(?P<ip>(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.
@@ -155,6 +161,7 @@ STREAM_ID = "(?P<stream_id>[T\d:>+*\-\$]+)"
DELTA = fr"(?P<delta>{NNUM})"
OFFSET = fr"(?P<offset>{NUM})" # string offset, can't be negative
+SHARP_OFFSET = fr"(?P<offset>#?{NUM})" # for bitfield command
MIN = fr"(?P<min>{NNUM})"
MAX = fr"(?P<max>{NNUM})"
POSITION = fr"(?P<position>{NNUM})"
@@ -227,6 +234,11 @@ JUSTID = fr"(?P<justid>{c('justid')})"
BLOCK = fr"(?P<block>{c('block')})"
STREAMS = fr"(?P<streams>{c('streams')})"
NOACK = fr"(?P<noack>{c('noack')})"
+GET = fr"(?P<get>{c('get')})"
+SET = fr"(?P<set>{c('set')})"
+INCRBY = fr"(?P<incrby>{c('incrby')})"
+OVERFLOW = fr"(?P<overflow>{c('overflow')})"
+OVERFLOW_OPTION = fr"(?P<overflow_option>{c('overflow_option')})"
# TODO test lexer & completer for multi spaces in command
# FIXME invalid command like "aaa bbb ccc"
@@ -432,6 +444,15 @@ NEW_GRAMMAR = {
\s+ {KEYS}
(\s+ {STREAM_ID})+
\s*""",
+ "command_bitfield": fr"""\s* (?P<command>xxin)
+ \s+ {KEY}
+ (
+ (\s+ {GET} \s+ {INTTYPE} \s+ {SHARP_OFFSET})|
+ (\s+ {SET} \s+ {INTTYPE} \s+ {SHARP_OFFSET} \s+ {VALUE})|
+ (\s+ {INCRBY} \s+ {INTTYPE} \s+ {SHARP_OFFSET} \s+ {VALUE})|
+ (\s+ {OVERFLOW} \s+ {OVERFLOW_OPTION})
+ )+
+ \s*""",
}
pipeline = r"(?P<shellcommand>\|.*)?"
