Add digit helper
This commit is contained in:
@@ -94,6 +94,7 @@ proc ch*(expectedChar: char): parserFnT {.inline.} =
|
||||
))
|
||||
|
||||
let anyCh* = ch(AllChars)
|
||||
let digit* = ch(Digits)
|
||||
|
||||
proc str*(s: string): parserFnT {.inline.} =
|
||||
return proc(parser: Parser): ParserResult =
|
||||
@@ -243,12 +244,10 @@ when isMainModule:
|
||||
|
||||
block testParsingFunctions:
|
||||
let ch1 = ch('1')
|
||||
let chDigits = ch(Digits)
|
||||
|
||||
# Success
|
||||
assert testParser123.flatMap(ch1).tokensToString() == "1"
|
||||
assert testParser123.flatMap(anyCh).tokensToString() == "1"
|
||||
assert testParser123.flatMap(chDigits).tokensToString() == "1"
|
||||
assert testParser123.flatMap(str("123")).tokensToString() == "123"
|
||||
|
||||
# Mismatch
|
||||
|
||||
Reference in New Issue
Block a user