Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions common/grammar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package common

// RESP data type names
const SimpleString = "SIMPLE_STRING"
const SimpleError = "SIMPLE_ERROR"
const Integer = "INTEGER"
const BulkString = "BULK_STRING"
const Array = "ARRAY"
16 changes: 5 additions & 11 deletions resp/grammar.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ package resp

import "HelixDB/common"

const SimpleString = "SIMPLE_STRING"
const SimpleError = "SIMPLE_ERROR"
const Integer = "INTEGER"
const BulkString = "BULK_STRING"
const Array = "ARRAY"

var DataTypeToFirstByteMap = map[string]string{
"+": SimpleString,
"-": SimpleError,
":": Integer,
"$": BulkString,
"*": Array,
"+": common.SimpleString,
"-": common.SimpleError,
":": common.Integer,
"$": common.BulkString,
"*": common.Array,
}

var FirstByteToDataTypeMap = common.ReverseMap(DataTypeToFirstByteMap)
2 changes: 1 addition & 1 deletion resp/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func ParseCommand(command []byte) (common.Cmd, error) {
return common.Cmd{}, UnsupportedCommandDataTypeError
}
data := strings.Split(string(command), common.Terminator)
if dataType == Array {
if dataType == common.Array {
return parseArray(data)
}
return common.Cmd{}, nil
Expand Down
Loading