use hexchar in stdlib (#16290)
This commit is contained in:
parent
8cd3655dee
commit
e1e069dd6c
7 changed files with 68 additions and 75 deletions
|
|
@ -12,6 +12,8 @@
|
|||
import
|
||||
hashes, strutils, lexbase, streams, unicode, macros
|
||||
|
||||
import std/private/decode_helpers
|
||||
|
||||
type
|
||||
SexpEventKind* = enum ## enumeration of all events that may occur when parsing
|
||||
sexpError, ## an error occurred during parsing
|
||||
|
|
@ -113,14 +115,6 @@ proc errorMsgExpected*(my: SexpParser, e: string): string =
|
|||
## other error messages
|
||||
result = "($1, $2) Error: $3" % [$getLine(my), $getColumn(my), e & " expected"]
|
||||
|
||||
proc handleHexChar(c: char, x: var int): bool =
|
||||
result = true # Success
|
||||
case c
|
||||
of '0'..'9': x = (x shl 4) or (ord(c) - ord('0'))
|
||||
of 'a'..'f': x = (x shl 4) or (ord(c) - ord('a') + 10)
|
||||
of 'A'..'F': x = (x shl 4) or (ord(c) - ord('A') + 10)
|
||||
else: result = false # error
|
||||
|
||||
proc parseString(my: var SexpParser): TTokKind =
|
||||
result = tkString
|
||||
var pos = my.bufpos + 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue