fix: reading unicode chars + tests

This commit is contained in:
Roland Sadowski 2020-01-30 20:08:00 +00:00
parent fe1685b4b6
commit e0968b3b7d
2 changed files with 7 additions and 1 deletions

View File

@ -425,7 +425,7 @@ proc read_character(p: var EdnParser): EdnNode =
elif token == "return":
result.character = "\r"
elif token.startsWith("u"):
result.character = parse_hex_str(token)
result.character = parse_hex_str(token.substr(1))
elif token.startsWith("o"):
# TODO: impl unicode char reading
raise new_exception(ParseError, "Not implemented: reading unicode chars")

View File

@ -317,6 +317,12 @@ test "everything":
except ParseError:
discard
node = read("\"\uffff\"")
check node.kind == EdnString
node = read("\\uffff")
check node.kind == EdnCharacter
node = read("()") # for the following to work
var n1: EdnNode = EdnNode(kind: EdnNil)
var n2: EdnNode = EdnNode(kind: EdnNil)