implemented extended quoting rules
This commit is contained in:
parent
0bcdab8395
commit
6c5693e633
11 changed files with 317 additions and 415 deletions
|
|
@ -7,10 +7,10 @@ proc callC() = callA()
|
|||
try:
|
||||
callC()
|
||||
except EAssertionFailed:
|
||||
write(stdout, "assertion failure!\n")
|
||||
write(stdout, "assertion failure!")
|
||||
except:
|
||||
write(stdout, "unknown exception!\n")
|
||||
write(stdout, "unknown exception!")
|
||||
finally:
|
||||
system.write(stdout, "this shall be always written\n")
|
||||
system.write(stdout, "this shall be always written")
|
||||
|
||||
assert(false)
|
||||
assert(false) #OUT assertion failure!this shall be always written
|
||||
|
|
|
|||
20
tests/tinvalidnewseq.nim
Executable file
20
tests/tinvalidnewseq.nim
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
import regexprs, strutils
|
||||
|
||||
type
|
||||
TURL = tuple[protocol, subdomain, domain, port: string, path: seq[string]]
|
||||
|
||||
proc parseURL(url: string): TURL =
|
||||
#([a-zA-Z]+://)?(\w+?\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)?
|
||||
var pattern: string = r"([a-zA-Z]+://)?(\w+?\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)?"
|
||||
var m: array[0..6, string] #Array with the matches
|
||||
newSeq(m, 7) #ERROR
|
||||
discard regexprs.match(url, pattern, m)
|
||||
|
||||
result = (protocol: m[1], subdomain: m[2], domain: m[3] & m[4],
|
||||
port: m[5], path: m[6].split('/'))
|
||||
|
||||
var r: TUrl
|
||||
|
||||
r = parseUrl(r"http://google.com/search?var=bleahdhsad")
|
||||
echo(r.domain)
|
||||
|
||||
14
tests/tstrlits.nim
Executable file
14
tests/tstrlits.nim
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
# Test the new different string literals
|
||||
|
||||
const
|
||||
tripleEmpty = """"long string"""""""" # "long string """""
|
||||
|
||||
rawQuote = r"a"""
|
||||
|
||||
raw = r"abc""def"
|
||||
|
||||
stdout.write(rawQuote)
|
||||
stdout.write(tripleEmpty)
|
||||
stdout.write(raw)
|
||||
#OUT a""long string"""""abc"def
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue