parseutils.html 223 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>std/parseutils</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  14. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">std/parseutils</h1>
  24. <div class="row">
  25. <div class="three columns">
  26. <div class="theme-select-wrapper">
  27. <label for="theme-select">Theme:&nbsp;</label>
  28. <select id="theme-select" onchange="setTheme(this.value)">
  29. <option value="auto">🌗 Match OS</option>
  30. <option value="dark">🌑 Dark</option>
  31. <option value="light">🌕 Light</option>
  32. </select>
  33. </div>
  34. <div id="global-links">
  35. <ul class="simple-boot">
  36. <li><a href="manual.html">Manual</a></li>
  37. <li><a href="lib.html">Standard library</a></li>
  38. <li> <a id="indexLink" href="theindex.html">Index</a></li>
  39. <li><a href="compiler/theindex.html">Compiler docs</a></li>
  40. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  41. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  42. </ul>
  43. </div>
  44. <div id="searchInputDiv">
  45. Search: <input type="search" id="searchInput"
  46. oninput="search()" />
  47. </div>
  48. <ul class="simple simple-toc" id="toc-list">
  49. <li>
  50. <details open>
  51. <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
  52. <ul class="simple simple-toc-section">
  53. <li><a class="reference" href="#InterpolatedKind" title="InterpolatedKind = enum
  54. ikStr, ## ``str`` part of the interpolated string
  55. ikDollar, ## escaped ``$`` part of the interpolated string
  56. ikVar, ## ``var`` part of the interpolated string
  57. ikExpr ## ``expr`` part of the interpolated string">InterpolatedKind</a></li>
  58. </ul>
  59. </details>
  60. </li>
  61. <li>
  62. <details open>
  63. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  64. <ul class="simple simple-toc-section">
  65. <ul class="simple nested-toc-section">captureBetween
  66. <li><a class="reference" href="#captureBetween%2CopenArray%5Bchar%5D%2Cchar%2Cchar" title="captureBetween(s: openArray[char]; first: char; second = '\x00'): string">captureBetween(s: openArray[char]; first: char; second = '\x00'): string</a></li>
  67. <li><a class="reference" href="#captureBetween%2Cstring%2Cchar%2Cchar%2Cint" title="captureBetween(s: string; first: char; second = '\x00'; start = 0): string">captureBetween(s: string; first: char; second = '\x00'; start = 0): string</a></li>
  68. </ul>
  69. <ul class="simple nested-toc-section">parseBiggestFloat
  70. <li><a class="reference" href="#parseBiggestFloat%2CopenArray%5Bchar%5D%2CBiggestFloat" title="parseBiggestFloat(s: openArray[char]; number: var BiggestFloat): int">parseBiggestFloat(s: openArray[char]; number: var BiggestFloat): int</a></li>
  71. <li><a class="reference" href="#parseBiggestFloat%2Cstring%2CBiggestFloat%2Cint" title="parseBiggestFloat(s: string; number: var BiggestFloat; start = 0): int">parseBiggestFloat(s: string; number: var BiggestFloat; start = 0): int</a></li>
  72. </ul>
  73. <ul class="simple nested-toc-section">parseBiggestInt
  74. <li><a class="reference" href="#parseBiggestInt%2CopenArray%5Bchar%5D%2CBiggestInt" title="parseBiggestInt(s: openArray[char]; number: var BiggestInt): int">parseBiggestInt(s: openArray[char]; number: var BiggestInt): int</a></li>
  75. <li><a class="reference" href="#parseBiggestInt%2Cstring%2CBiggestInt%2Cint" title="parseBiggestInt(s: string; number: var BiggestInt; start = 0): int">parseBiggestInt(s: string; number: var BiggestInt; start = 0): int</a></li>
  76. </ul>
  77. <ul class="simple nested-toc-section">parseBiggestUInt
  78. <li><a class="reference" href="#parseBiggestUInt%2CopenArray%5Bchar%5D%2CBiggestUInt" title="parseBiggestUInt(s: openArray[char]; number: var BiggestUInt): int">parseBiggestUInt(s: openArray[char]; number: var BiggestUInt): int</a></li>
  79. <li><a class="reference" href="#parseBiggestUInt%2Cstring%2CBiggestUInt%2Cint" title="parseBiggestUInt(s: string; number: var BiggestUInt; start = 0): int">parseBiggestUInt(s: string; number: var BiggestUInt; start = 0): int</a></li>
  80. </ul>
  81. <ul class="simple nested-toc-section">parseBin
  82. <li><a class="reference" href="#parseBin%2CopenArray%5Bchar%5D%2CT%2Cint" title="parseBin[T: SomeInteger](s: openArray[char]; number: var T; maxLen = 0): int">parseBin[T: SomeInteger](s: openArray[char]; number: var T; maxLen = 0): int</a></li>
  83. <li><a class="reference" href="#parseBin%2Cstring%2CT%2Cint%2Cint" title="parseBin[T: SomeInteger](s: string; number: var T; start = 0; maxLen = 0): int">parseBin[T: SomeInteger](s: string; number: var T; start = 0; maxLen = 0): int</a></li>
  84. </ul>
  85. <ul class="simple nested-toc-section">parseChar
  86. <li><a class="reference" href="#parseChar%2CopenArray%5Bchar%5D%2Cchar" title="parseChar(s: openArray[char]; c: var char): int">parseChar(s: openArray[char]; c: var char): int</a></li>
  87. <li><a class="reference" href="#parseChar%2Cstring%2Cchar%2Cint" title="parseChar(s: string; c: var char; start = 0): int">parseChar(s: string; c: var char; start = 0): int</a></li>
  88. </ul>
  89. <ul class="simple nested-toc-section">parseFloat
  90. <li><a class="reference" href="#parseFloat%2CopenArray%5Bchar%5D%2Cfloat" title="parseFloat(s: openArray[char]; number: var float): int">parseFloat(s: openArray[char]; number: var float): int</a></li>
  91. <li><a class="reference" href="#parseFloat%2Cstring%2Cfloat%2Cint" title="parseFloat(s: string; number: var float; start = 0): int">parseFloat(s: string; number: var float; start = 0): int</a></li>
  92. </ul>
  93. <ul class="simple nested-toc-section">parseHex
  94. <li><a class="reference" href="#parseHex%2CopenArray%5Bchar%5D%2CT%2Cint" title="parseHex[T: SomeInteger](s: openArray[char]; number: var T; maxLen = 0): int">parseHex[T: SomeInteger](s: openArray[char]; number: var T; maxLen = 0): int</a></li>
  95. <li><a class="reference" href="#parseHex%2Cstring%2CT%2Cint%2Cint" title="parseHex[T: SomeInteger](s: string; number: var T; start = 0; maxLen = 0): int">parseHex[T: SomeInteger](s: string; number: var T; start = 0; maxLen = 0): int</a></li>
  96. </ul>
  97. <ul class="simple nested-toc-section">parseIdent
  98. <li><a class="reference" href="#parseIdent%2CopenArray%5Bchar%5D" title="parseIdent(s: openArray[char]): string">parseIdent(s: openArray[char]): string</a></li>
  99. <li><a class="reference" href="#parseIdent%2CopenArray%5Bchar%5D%2Cstring" title="parseIdent(s: openArray[char]; ident: var string): int">parseIdent(s: openArray[char]; ident: var string): int</a></li>
  100. <li><a class="reference" href="#parseIdent%2Cstring%2Cstring%2Cint" title="parseIdent(s: string; ident: var string; start = 0): int">parseIdent(s: string; ident: var string; start = 0): int</a></li>
  101. <li><a class="reference" href="#parseIdent%2Cstring%2Cint" title="parseIdent(s: string; start = 0): string">parseIdent(s: string; start = 0): string</a></li>
  102. </ul>
  103. <ul class="simple nested-toc-section">parseInt
  104. <li><a class="reference" href="#parseInt%2CopenArray%5Bchar%5D%2Cint" title="parseInt(s: openArray[char]; number: var int): int">parseInt(s: openArray[char]; number: var int): int</a></li>
  105. <li><a class="reference" href="#parseInt%2Cstring%2Cint%2Cint" title="parseInt(s: string; number: var int; start = 0): int">parseInt(s: string; number: var int; start = 0): int</a></li>
  106. </ul>
  107. <ul class="simple nested-toc-section">parseOct
  108. <li><a class="reference" href="#parseOct%2CopenArray%5Bchar%5D%2CT%2Cint" title="parseOct[T: SomeInteger](s: openArray[char]; number: var T; maxLen = 0): int">parseOct[T: SomeInteger](s: openArray[char]; number: var T; maxLen = 0): int</a></li>
  109. <li><a class="reference" href="#parseOct%2Cstring%2CT%2Cint%2Cint" title="parseOct[T: SomeInteger](s: string; number: var T; start = 0; maxLen = 0): int">parseOct[T: SomeInteger](s: string; number: var T; start = 0; maxLen = 0): int</a></li>
  110. </ul>
  111. <ul class="simple nested-toc-section">parseSaturatedNatural
  112. <li><a class="reference" href="#parseSaturatedNatural%2CopenArray%5Bchar%5D%2Cint" title="parseSaturatedNatural(s: openArray[char]; b: var int): int">parseSaturatedNatural(s: openArray[char]; b: var int): int</a></li>
  113. <li><a class="reference" href="#parseSaturatedNatural%2Cstring%2Cint%2Cint" title="parseSaturatedNatural(s: string; b: var int; start = 0): int">parseSaturatedNatural(s: string; b: var int; start = 0): int</a></li>
  114. </ul>
  115. <ul class="simple nested-toc-section">parseSize
  116. <li><a class="reference" href="#parseSize%2CopenArray%5Bchar%5D%2Cint64" title="parseSize(s: openArray[char]; size: var int64; alwaysBin = false): int">parseSize(s: openArray[char]; size: var int64; alwaysBin = false): int</a></li>
  117. </ul>
  118. <ul class="simple nested-toc-section">parseUInt
  119. <li><a class="reference" href="#parseUInt%2CopenArray%5Bchar%5D%2Cuint" title="parseUInt(s: openArray[char]; number: var uint): int">parseUInt(s: openArray[char]; number: var uint): int</a></li>
  120. <li><a class="reference" href="#parseUInt%2Cstring%2Cuint%2Cint" title="parseUInt(s: string; number: var uint; start = 0): int">parseUInt(s: string; number: var uint; start = 0): int</a></li>
  121. </ul>
  122. <ul class="simple nested-toc-section">parseUntil
  123. <li><a class="reference" href="#parseUntil%2CopenArray%5Bchar%5D%2Cstring%2Cchar" title="parseUntil(s: openArray[char]; token: var string; until: char): int">parseUntil(s: openArray[char]; token: var string; until: char): int</a></li>
  124. <li><a class="reference" href="#parseUntil%2CopenArray%5Bchar%5D%2Cstring%2Cset%5Bchar%5D" title="parseUntil(s: openArray[char]; token: var string; until: set[char]): int">parseUntil(s: openArray[char]; token: var string; until: set[char]): int</a></li>
  125. <li><a class="reference" href="#parseUntil%2CopenArray%5Bchar%5D%2Cstring%2Cstring" title="parseUntil(s: openArray[char]; token: var string; until: string): int">parseUntil(s: openArray[char]; token: var string; until: string): int</a></li>
  126. <li><a class="reference" href="#parseUntil%2Cstring%2Cstring%2Cchar%2Cint" title="parseUntil(s: string; token: var string; until: char; start = 0): int">parseUntil(s: string; token: var string; until: char; start = 0): int</a></li>
  127. <li><a class="reference" href="#parseUntil%2Cstring%2Cstring%2Cset%5Bchar%5D%2Cint" title="parseUntil(s: string; token: var string; until: set[char]; start = 0): int">parseUntil(s: string; token: var string; until: set[char]; start = 0): int</a></li>
  128. <li><a class="reference" href="#parseUntil%2Cstring%2Cstring%2Cstring%2Cint" title="parseUntil(s: string; token: var string; until: string; start = 0): int">parseUntil(s: string; token: var string; until: string; start = 0): int</a></li>
  129. </ul>
  130. <ul class="simple nested-toc-section">parseWhile
  131. <li><a class="reference" href="#parseWhile%2CopenArray%5Bchar%5D%2Cstring%2Cset%5Bchar%5D" title="parseWhile(s: openArray[char]; token: var string; validChars: set[char]): int">parseWhile(s: openArray[char]; token: var string; validChars: set[char]): int</a></li>
  132. <li><a class="reference" href="#parseWhile%2Cstring%2Cstring%2Cset%5Bchar%5D%2Cint" title="parseWhile(s: string; token: var string; validChars: set[char]; start = 0): int">parseWhile(s: string; token: var string; validChars: set[char]; start = 0): int</a></li>
  133. </ul>
  134. <ul class="simple nested-toc-section">skip
  135. <li><a class="reference" href="#skip%2CopenArray%5Bchar%5D%2CopenArray%5Bchar%5D" title="skip(s, token: openArray[char]): int">skip(s, token: openArray[char]): int</a></li>
  136. <li><a class="reference" href="#skip%2Cstring%2Cstring%2Cint" title="skip(s, token: string; start = 0): int">skip(s, token: string; start = 0): int</a></li>
  137. </ul>
  138. <ul class="simple nested-toc-section">skipIgnoreCase
  139. <li><a class="reference" href="#skipIgnoreCase%2CopenArray%5Bchar%5D%2CopenArray%5Bchar%5D" title="skipIgnoreCase(s, token: openArray[char]): int">skipIgnoreCase(s, token: openArray[char]): int</a></li>
  140. <li><a class="reference" href="#skipIgnoreCase%2Cstring%2Cstring%2Cint" title="skipIgnoreCase(s, token: string; start = 0): int">skipIgnoreCase(s, token: string; start = 0): int</a></li>
  141. </ul>
  142. <ul class="simple nested-toc-section">skipUntil
  143. <li><a class="reference" href="#skipUntil%2CopenArray%5Bchar%5D%2Cchar" title="skipUntil(s: openArray[char]; until: char): int">skipUntil(s: openArray[char]; until: char): int</a></li>
  144. <li><a class="reference" href="#skipUntil%2CopenArray%5Bchar%5D%2Cset%5Bchar%5D" title="skipUntil(s: openArray[char]; until: set[char]): int">skipUntil(s: openArray[char]; until: set[char]): int</a></li>
  145. <li><a class="reference" href="#skipUntil%2Cstring%2Cchar%2Cint" title="skipUntil(s: string; until: char; start = 0): int">skipUntil(s: string; until: char; start = 0): int</a></li>
  146. <li><a class="reference" href="#skipUntil%2Cstring%2Cset%5Bchar%5D%2Cint" title="skipUntil(s: string; until: set[char]; start = 0): int">skipUntil(s: string; until: set[char]; start = 0): int</a></li>
  147. </ul>
  148. <ul class="simple nested-toc-section">skipWhile
  149. <li><a class="reference" href="#skipWhile%2CopenArray%5Bchar%5D%2Cset%5Bchar%5D" title="skipWhile(s: openArray[char]; toSkip: set[char]): int">skipWhile(s: openArray[char]; toSkip: set[char]): int</a></li>
  150. <li><a class="reference" href="#skipWhile%2Cstring%2Cset%5Bchar%5D%2Cint" title="skipWhile(s: string; toSkip: set[char]; start = 0): int">skipWhile(s: string; toSkip: set[char]; start = 0): int</a></li>
  151. </ul>
  152. <ul class="simple nested-toc-section">skipWhitespace
  153. <li><a class="reference" href="#skipWhitespace%2CopenArray%5Bchar%5D" title="skipWhitespace(s: openArray[char]): int">skipWhitespace(s: openArray[char]): int</a></li>
  154. <li><a class="reference" href="#skipWhitespace%2Cstring%2Cint" title="skipWhitespace(s: string; start = 0): int">skipWhitespace(s: string; start = 0): int</a></li>
  155. </ul>
  156. </ul>
  157. </details>
  158. </li>
  159. <li>
  160. <details open>
  161. <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
  162. <ul class="simple simple-toc-section">
  163. <ul class="simple nested-toc-section">interpolatedFragments
  164. <li><a class="reference" href="#interpolatedFragments.i%2CopenArray%5Bchar%5D" title="interpolatedFragments(s: openArray[char]): tuple[kind: InterpolatedKind,
  165. value: string]">interpolatedFragments(s: openArray[char]): tuple[kind: InterpolatedKind,
  166. value: string]</a></li>
  167. <li><a class="reference" href="#interpolatedFragments.i%2Cstring" title="interpolatedFragments(s: string): tuple[kind: InterpolatedKind, value: string]">interpolatedFragments(s: string): tuple[kind: InterpolatedKind, value: string]</a></li>
  168. </ul>
  169. </ul>
  170. </details>
  171. </li>
  172. </ul>
  173. </div>
  174. <div class="nine columns" id="content">
  175. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  176. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  177. <div id="tocRoot"></div>
  178. <p class="module-desc"><p>This module contains helpers for parsing tokens, numbers, integers, floats, identifiers, etc.</p>
  179. <p>To unpack raw bytes look at the <a class="reference external" href="streams.html">streams</a> module.</p>
  180. <p><pre class="listing"><span class="Keyword">let</span> <span class="Identifier">logs</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">&quot;2019-01-10: OK_&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;2019-01-11: FAIL_&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;2019-01: aaaa&quot;</span><span class="Punctuation">]</span>
  181. <span class="Keyword">var</span> <span class="Identifier">outp</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span>
  182. <span class="Keyword">for</span> <span class="Identifier">log</span> <span class="Keyword">in</span> <span class="Identifier">logs</span><span class="Punctuation">:</span>
  183. <span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  184. <span class="Keyword">if</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="Identifier">log</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="CharLit">':'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">10</span><span class="Punctuation">:</span> <span class="Comment"># YYYY-MM-DD == 10</span>
  185. <span class="Identifier">outp</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">res</span> <span class="Operator">&amp;</span> <span class="StringLit">&quot; - &quot;</span> <span class="Operator">&amp;</span> <span class="Identifier">captureBetween</span><span class="Punctuation">(</span><span class="Identifier">log</span><span class="Punctuation">,</span> <span class="CharLit">' '</span><span class="Punctuation">,</span> <span class="CharLit">'_'</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  186. <span class="Identifier">doAssert</span> <span class="Identifier">outp</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">&quot;2019-01-10 - OK&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;2019-01-11 - FAIL&quot;</span><span class="Punctuation">]</span></pre></p>
  187. <p><pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">strutils</span> <span class="Keyword">import</span> <span class="Identifier">Digits</span><span class="Punctuation">,</span> <span class="Identifier">parseInt</span>
  188. <span class="Keyword">let</span>
  189. <span class="Identifier">input1</span> <span class="Operator">=</span> <span class="StringLit">&quot;2019 school start&quot;</span>
  190. <span class="Identifier">input2</span> <span class="Operator">=</span> <span class="StringLit">&quot;3 years back&quot;</span>
  191. <span class="Identifier">startYear</span> <span class="Operator">=</span> <span class="Identifier">input1</span><span class="Punctuation">[</span><span class="DecNumber">0</span> <span class="Operator">..</span> <span class="Identifier">skipWhile</span><span class="Punctuation">(</span><span class="Identifier">input1</span><span class="Punctuation">,</span> <span class="Identifier">Digits</span><span class="Punctuation">)</span><span class="Operator">-</span><span class="DecNumber">1</span><span class="Punctuation">]</span> <span class="Comment"># 2019</span>
  192. <span class="Identifier">yearsBack</span> <span class="Operator">=</span> <span class="Identifier">input2</span><span class="Punctuation">[</span><span class="DecNumber">0</span> <span class="Operator">..</span> <span class="Identifier">skipWhile</span><span class="Punctuation">(</span><span class="Identifier">input2</span><span class="Punctuation">,</span> <span class="Identifier">Digits</span><span class="Punctuation">)</span><span class="Operator">-</span><span class="DecNumber">1</span><span class="Punctuation">]</span> <span class="Comment"># 3</span>
  193. <span class="Identifier">examYear</span> <span class="Operator">=</span> <span class="Identifier">parseInt</span><span class="Punctuation">(</span><span class="Identifier">startYear</span><span class="Punctuation">)</span> <span class="Operator">+</span> <span class="Identifier">parseInt</span><span class="Punctuation">(</span><span class="Identifier">yearsBack</span><span class="Punctuation">)</span>
  194. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;Examination is in &quot;</span> <span class="Operator">&amp;</span> <span class="Operator">$</span><span class="Identifier">examYear</span> <span class="Operator">==</span> <span class="StringLit">&quot;Examination is in 2022&quot;</span></pre></p>
  195. <p><strong>See also:</strong></p>
  196. <ul class="simple"><li><a class="reference external" href="strutils.html">strutils module</a> for combined and identical parsing proc's</li>
  197. <li><a class="reference external" href="json.html">json module</a> for a JSON parser</li>
  198. <li><a class="reference external" href="parsecfg.html">parsecfg module</a> for a configuration file parser</li>
  199. <li><a class="reference external" href="parsecsv.html">parsecsv module</a> for a simple CSV (comma separated value) parser</li>
  200. <li><a class="reference external" href="parseopt.html">parseopt module</a> for a command line parser</li>
  201. <li><a class="reference external" href="parsexml.html">parsexml module</a> for a XML / HTML parser</li>
  202. <li><a class="reference external" href="lib.html#pure-libraries-parsers">other parsers</a> for other parsers</li>
  203. </ul>
  204. </p>
  205. <div class="section" id="7">
  206. <h1><a class="toc-backref" href="#7">Types</a></h1>
  207. <dl class="item">
  208. <div id="InterpolatedKind">
  209. <dt><pre><a href="parseutils.html#InterpolatedKind"><span class="Identifier">InterpolatedKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  210. <span class="Identifier">ikStr</span><span class="Other">,</span> <span class="Comment">## ``str`` part of the interpolated string</span>
  211. <span class="Identifier">ikDollar</span><span class="Other">,</span> <span class="Comment">## escaped ``$`` part of the interpolated string</span>
  212. <span class="Identifier">ikVar</span><span class="Other">,</span> <span class="Comment">## ``var`` part of the interpolated string</span>
  213. <span class="Identifier">ikExpr</span> <span class="Comment">## ``expr`` part of the interpolated string</span></pre></dt>
  214. <dd>
  215. Describes for <tt class="docutils literal"><span class="pre"><span class="Identifier">interpolatedFragments</span></span></tt> which part of the interpolated string is yielded; for example in &quot;str$$$var${expr}&quot;
  216. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L676" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  217. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L676" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  218. </dd>
  219. </div>
  220. </dl>
  221. </div>
  222. <div class="section" id="12">
  223. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  224. <dl class="item">
  225. <div id="captureBetween-procs-all">
  226. <div id="captureBetween,openArray[char],char,char">
  227. <dt><pre><span class="Keyword">proc</span> <a href="#captureBetween%2CopenArray%5Bchar%5D%2Cchar%2Cchar"><span class="Identifier">captureBetween</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">first</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">;</span> <span class="Identifier">second</span> <span class="Other">=</span> <span class="CharLit">'\x00'</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
  228. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  229. <dd>
  230. Finds the first occurrence of <tt class="docutils literal"><span class="pre">first</span></tt>, then returns everything from there up to <tt class="docutils literal"><span class="pre">second</span></tt> (if <tt class="docutils literal"><span class="pre">second</span></tt> is '0', then <tt class="docutils literal"><span class="pre">first</span></tt> is used).
  231. <p><strong class="examples_text">Example:</strong></p>
  232. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">captureBetween</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'e'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;llo World&quot;</span>
  233. <span class="Identifier">doAssert</span> <span class="Identifier">captureBetween</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'e'</span><span class="Punctuation">,</span> <span class="CharLit">'r'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;llo Wo&quot;</span>
  234. <span class="Identifier">doAssert</span> <span class="Identifier">captureBetween</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Operator">.</span><span class="Identifier">toOpenArray</span><span class="Punctuation">(</span><span class="DecNumber">6</span><span class="Punctuation">,</span> <span class="StringLit">&quot;Hello World&quot;</span><span class="Operator">.</span><span class="Identifier">high</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="CharLit">'l'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;d&quot;</span></pre>
  235. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L418" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  236. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L418" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  237. </dd>
  238. </div>
  239. <div id="captureBetween,string,char,char,int">
  240. <dt><pre><span class="Keyword">proc</span> <a href="#captureBetween%2Cstring%2Cchar%2Cchar%2Cint"><span class="Identifier">captureBetween</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">first</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">;</span> <span class="Identifier">second</span> <span class="Other">=</span> <span class="CharLit">'\x00'</span><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
  241. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  242. <dd>
  243. Finds the first occurrence of <tt class="docutils literal"><span class="pre">first</span></tt>, then returns everything from there up to <tt class="docutils literal"><span class="pre">second</span></tt> (if <tt class="docutils literal"><span class="pre">second</span></tt> is '0', then <tt class="docutils literal"><span class="pre">first</span></tt> is used).
  244. <p><strong class="examples_text">Example:</strong></p>
  245. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">captureBetween</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'e'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;llo World&quot;</span>
  246. <span class="Identifier">doAssert</span> <span class="Identifier">captureBetween</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'e'</span><span class="Punctuation">,</span> <span class="CharLit">'r'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;llo Wo&quot;</span>
  247. <span class="Identifier">doAssert</span> <span class="Identifier">captureBetween</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'l'</span><span class="Punctuation">,</span> <span class="Identifier">start</span> <span class="Operator">=</span> <span class="DecNumber">6</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;d&quot;</span></pre>
  248. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L994" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  249. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L994" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  250. </dd>
  251. </div>
  252. </div>
  253. <div id="parseBiggestFloat-procs-all">
  254. <div id="parseBiggestFloat,openArray[char],BiggestFloat">
  255. <dt><pre><span class="Keyword">proc</span> <a href="#parseBiggestFloat%2CopenArray%5Bchar%5D%2CBiggestFloat"><span class="Identifier">parseBiggestFloat</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ctypes.html#BiggestFloat"><span class="Identifier">BiggestFloat</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  256. <span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">&quot;ParseBiggestFloat&quot;</span><span class="Other">,</span> <span class="Identifier">importc</span><span class="Other">:</span> <span class="StringLit">&quot;nimParseBiggestFloat&quot;</span><span class="Other">,</span> <span class="Identifier">noSideEffect</span><span class="Other">,</span>
  257. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  258. <dd>
  259. Parses a float and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. Result is the number of processed chars or 0 if a parsing error occurred.
  260. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L586" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  261. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L586" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  262. </dd>
  263. </div>
  264. <div id="parseBiggestFloat,string,BiggestFloat,int">
  265. <dt><pre><span class="Keyword">proc</span> <a href="#parseBiggestFloat%2Cstring%2CBiggestFloat%2Cint"><span class="Identifier">parseBiggestFloat</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ctypes.html#BiggestFloat"><span class="Identifier">BiggestFloat</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  266. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  267. <dd>
  268. Parses a float starting at <tt class="docutils literal"><span class="pre"><span class="Identifier">start</span></span></tt> and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. Result is the number of processed chars or 0 if a parsing error occurred.
  269. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1067" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  270. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1067" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  271. </dd>
  272. </div>
  273. </div>
  274. <div id="parseBiggestInt-procs-all">
  275. <div id="parseBiggestInt,openArray[char],BiggestInt">
  276. <dt><pre><span class="Keyword">proc</span> <a href="#parseBiggestInt%2CopenArray%5Bchar%5D%2CBiggestInt"><span class="Identifier">parseBiggestInt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  277. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;npuParseBiggestInt&quot;</span><span class="Other">,</span> </span><span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  278. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  279. <dd>
  280. Parses an integer and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. Result is the number of processed chars or 0 if there is no integer. <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> is raised if the parsed integer is out of the valid range.
  281. <p><strong class="examples_text">Example:</strong></p>
  282. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">BiggestInt</span>
  283. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;9223372036854775807&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">19</span>
  284. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">9223372036854775807</span>
  285. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;-2024_05_09&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  286. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">20240509</span></pre>
  287. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L466" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  288. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L466" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  289. </dd>
  290. </div>
  291. <div id="parseBiggestInt,string,BiggestInt,int">
  292. <dt><pre><span class="Keyword">proc</span> <a href="#parseBiggestInt%2Cstring%2CBiggestInt%2Cint"><span class="Identifier">parseBiggestInt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  293. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  294. <dd>
  295. Parses an integer starting at <tt class="docutils literal"><span class="pre"><span class="Identifier">start</span></span></tt> and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. Result is the number of processed chars or 0 if there is no integer. <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> is raised if the parsed integer is out of the valid range.
  296. <p><strong class="examples_text">Example:</strong></p>
  297. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">BiggestInt</span>
  298. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;9223372036854775807&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">19</span>
  299. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">9223372036854775807</span>
  300. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;-2024_05_09&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  301. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">20240509</span>
  302. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;-2024_05_02&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  303. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">502</span></pre>
  304. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1003" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  305. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1003" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  306. </dd>
  307. </div>
  308. </div>
  309. <div id="parseBiggestUInt-procs-all">
  310. <div id="parseBiggestUInt,openArray[char],BiggestUInt">
  311. <dt><pre><span class="Keyword">proc</span> <a href="#parseBiggestUInt%2CopenArray%5Bchar%5D%2CBiggestUInt"><span class="Identifier">parseBiggestUInt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ctypes.html#BiggestUInt"><span class="Identifier">BiggestUInt</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  312. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;npuParseBiggestUInt&quot;</span><span class="Other">,</span> </span><span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">]</span><span class="Other">,</span>
  313. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  314. <dd>
  315. Parses an unsigned integer and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> is raised if the parsed integer is out of the valid range.
  316. <p><strong class="examples_text">Example:</strong></p>
  317. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">BiggestUInt</span>
  318. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestUInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;12&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  319. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">12</span>
  320. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestUInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;1111111111111111111&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">19</span>
  321. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">1111111111111111111'</span><span class="Identifier">u64</span></pre>
  322. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L549" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  323. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L549" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  324. </dd>
  325. </div>
  326. <div id="parseBiggestUInt,string,BiggestUInt,int">
  327. <dt><pre><span class="Keyword">proc</span> <a href="#parseBiggestUInt%2Cstring%2CBiggestUInt%2Cint"><span class="Identifier">parseBiggestUInt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ctypes.html#BiggestUInt"><span class="Identifier">BiggestUInt</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  328. <span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  329. <dd>
  330. Parses an unsigned integer starting at <tt class="docutils literal"><span class="pre"><span class="Identifier">start</span></span></tt> and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> is raised if the parsed integer is out of the valid range.
  331. <p><strong class="examples_text">Example:</strong></p>
  332. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">BiggestUInt</span>
  333. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestUInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;12&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  334. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">12</span>
  335. <span class="Identifier">doAssert</span> <span class="Identifier">parseBiggestUInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;1111111111111111111&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">19</span>
  336. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">1111111111111111111'</span><span class="Identifier">u64</span></pre>
  337. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1043" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  338. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1043" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  339. </dd>
  340. </div>
  341. </div>
  342. <div id="parseBin-procs-all">
  343. <div id="parseBin,openArray[char],T,int">
  344. <dt><pre><span class="Keyword">proc</span> <a href="#parseBin%2CopenArray%5Bchar%5D%2CT%2Cint"><span class="Identifier">parseBin</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">maxLen</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  345. <span class="Identifier">noSideEffect</span>.}</pre></dt>
  346. <dd>
  347. <p>Parses a binary number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
  348. <p>Returns the number of the parsed characters or 0 in case of an error. If error, the value of <tt class="docutils literal"><span class="pre">number</span></tt> is not changed.</p>
  349. <p>If <tt class="docutils literal"><span class="pre">maxLen == 0</span></tt>, the parsing continues until the first non-bin character or to the end of the string. Otherwise, no more than <tt class="docutils literal"><span class="pre">maxLen</span></tt> characters are parsed starting from the <tt class="docutils literal"><span class="pre">start</span></tt> position.</p>
  350. <p>It does not check for overflow. If the value represented by the string is too big to fit into <tt class="docutils literal"><span class="pre">number</span></tt>, only the value of last fitting characters will be stored in <tt class="docutils literal"><span class="pre">number</span></tt> without producing an error.</p>
  351. <p><strong class="examples_text">Example:</strong></p>
  352. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  353. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0100_1110_0110_1001_1110_1101&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">29</span>
  354. <span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
  355. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;3&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  356. <span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
  357. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0b_0100_1110_0110_1001_1110_1101&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">32</span>
  358. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="BinNumber">0b1110_1101'i8</span>
  359. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0b_0100_1110_0110_1001_1110_1101&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">9</span>
  360. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="BinNumber">0b0100_1110'i8</span>
  361. <span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
  362. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0b_0100_1110_0110_1001_1110_1101&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8u</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">32</span>
  363. <span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
  364. <span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
  365. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0100111001101001111011010100111001101001&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num64</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">40</span>
  366. <span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">336784608873</span></pre>
  367. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L63" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  368. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L63" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  369. </dd>
  370. </div>
  371. <div id="parseBin,string,T,int,int">
  372. <dt><pre><span class="Keyword">proc</span> <a href="#parseBin%2Cstring%2CT%2Cint%2Cint"><span class="Identifier">parseBin</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">;</span> <span class="Identifier">maxLen</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  373. <span class="Identifier">noSideEffect</span>.}</pre></dt>
  374. <dd>
  375. <p>Parses a binary number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
  376. <p>Returns the number of the parsed characters or 0 in case of an error. If error, the value of <tt class="docutils literal"><span class="pre">number</span></tt> is not changed.</p>
  377. <p>If <tt class="docutils literal"><span class="pre">maxLen == 0</span></tt>, the parsing continues until the first non-bin character or to the end of the string. Otherwise, no more than <tt class="docutils literal"><span class="pre">maxLen</span></tt> characters are parsed starting from the <tt class="docutils literal"><span class="pre">start</span></tt> position.</p>
  378. <p>It does not check for overflow. If the value represented by the string is too big to fit into <tt class="docutils literal"><span class="pre">number</span></tt>, only the value of last fitting characters will be stored in <tt class="docutils literal"><span class="pre">number</span></tt> without producing an error.</p>
  379. <p><strong class="examples_text">Example:</strong></p>
  380. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  381. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0100_1110_0110_1001_1110_1101&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">29</span>
  382. <span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
  383. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;3&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  384. <span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
  385. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0b_0100_1110_0110_1001_1110_1101&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">32</span>
  386. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="BinNumber">0b1110_1101'i8</span>
  387. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0b_0100_1110_0110_1001_1110_1101&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">9</span>
  388. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="BinNumber">0b0100_1110'i8</span>
  389. <span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
  390. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0b_0100_1110_0110_1001_1110_1101&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8u</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">32</span>
  391. <span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
  392. <span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
  393. <span class="Identifier">doAssert</span> <span class="Identifier">parseBin</span><span class="Punctuation">(</span><span class="StringLit">&quot;0100111001101001111011010100111001101001&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num64</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">40</span>
  394. <span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">336784608873</span></pre>
  395. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L747" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  396. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L747" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  397. </dd>
  398. </div>
  399. </div>
  400. <div id="parseChar-procs-all">
  401. <div id="parseChar,openArray[char],char">
  402. <dt><pre><span class="Keyword">proc</span> <a href="#parseChar%2CopenArray%5Bchar%5D%2Cchar"><span class="Identifier">parseChar</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  403. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  404. <dd>
  405. Parses a single character, stores it in <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> and returns 1. In case of error (if start &gt;= s.len) it returns 0 and the value of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> is unchanged.
  406. <p><strong class="examples_text">Example:</strong></p>
  407. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">char</span>
  408. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;nim&quot;</span><span class="Operator">.</span><span class="Identifier">parseChar</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  409. <span class="Identifier">doAssert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="CharLit">'\0'</span>
  410. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;nim&quot;</span><span class="Operator">.</span><span class="Identifier">parseChar</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
  411. <span class="Identifier">doAssert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="CharLit">'n'</span></pre>
  412. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L251" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  413. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L251" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  414. </dd>
  415. </div>
  416. <div id="parseChar,string,char,int">
  417. <dt><pre><span class="Keyword">proc</span> <a href="#parseChar%2Cstring%2Cchar%2Cint"><span class="Identifier">parseChar</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  418. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  419. <dd>
  420. Parses a single character, stores it in <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> and returns 1. In case of error (if start &gt;= s.len) it returns 0 and the value of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> is unchanged.
  421. <p><strong class="examples_text">Example:</strong></p>
  422. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">char</span>
  423. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;nim&quot;</span><span class="Operator">.</span><span class="Identifier">parseChar</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  424. <span class="Identifier">doAssert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="CharLit">'\0'</span>
  425. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;nim&quot;</span><span class="Operator">.</span><span class="Identifier">parseChar</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
  426. <span class="Identifier">doAssert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="CharLit">'n'</span></pre>
  427. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L868" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  428. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L868" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  429. </dd>
  430. </div>
  431. </div>
  432. <div id="parseFloat-procs-all">
  433. <div id="parseFloat,openArray[char],float">
  434. <dt><pre><span class="Keyword">proc</span> <a href="#parseFloat%2CopenArray%5Bchar%5D%2Cfloat"><span class="Identifier">parseFloat</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#float"><span class="Identifier">float</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  435. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;npuParseFloat&quot;</span><span class="Other">,</span> </span><span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  436. <dd>
  437. Parses a float and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. Result is the number of processed chars or 0 if there occurred a parsing error.
  438. <p><strong class="examples_text">Example:</strong></p>
  439. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">float</span>
  440. <span class="Identifier">doAssert</span> <span class="Identifier">parseFloat</span><span class="Punctuation">(</span><span class="StringLit">&quot;32&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  441. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">32.0</span>
  442. <span class="Identifier">doAssert</span> <span class="Identifier">parseFloat</span><span class="Punctuation">(</span><span class="StringLit">&quot;32.57&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
  443. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">32.57</span>
  444. <span class="Identifier">doAssert</span> <span class="Identifier">parseFloat</span><span class="Punctuation">(</span><span class="StringLit">&quot;32.57&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  445. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">57.00</span></pre>
  446. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L592" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  447. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L592" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  448. </dd>
  449. </div>
  450. <div id="parseFloat,string,float,int">
  451. <dt><pre><span class="Keyword">proc</span> <a href="#parseFloat%2Cstring%2Cfloat%2Cint"><span class="Identifier">parseFloat</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#float"><span class="Identifier">float</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span>
  452. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  453. <dd>
  454. Parses a float starting at <tt class="docutils literal"><span class="pre"><span class="Identifier">start</span></span></tt> and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. Result is the number of processed chars or 0 if there occurred a parsing error.
  455. <p><strong class="examples_text">Example:</strong></p>
  456. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">float</span>
  457. <span class="Identifier">doAssert</span> <span class="Identifier">parseFloat</span><span class="Punctuation">(</span><span class="StringLit">&quot;32&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  458. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">32.0</span>
  459. <span class="Identifier">doAssert</span> <span class="Identifier">parseFloat</span><span class="Punctuation">(</span><span class="StringLit">&quot;32.57&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
  460. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">32.57</span>
  461. <span class="Identifier">doAssert</span> <span class="Identifier">parseFloat</span><span class="Punctuation">(</span><span class="StringLit">&quot;32.57&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  462. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">57.00</span></pre>
  463. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1073" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  464. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1073" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  465. </dd>
  466. </div>
  467. </div>
  468. <div id="parseHex-procs-all">
  469. <div id="parseHex,openArray[char],T,int">
  470. <dt><pre><span class="Keyword">proc</span> <a href="#parseHex%2CopenArray%5Bchar%5D%2CT%2Cint"><span class="Identifier">parseHex</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">maxLen</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  471. <span class="Identifier">noSideEffect</span>.}</pre></dt>
  472. <dd>
  473. <p>Parses a hexadecimal number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
  474. <p>Returns the number of the parsed characters or 0 in case of an error. If error, the value of <tt class="docutils literal"><span class="pre">number</span></tt> is not changed.</p>
  475. <p>If <tt class="docutils literal"><span class="pre">maxLen == 0</span></tt>, the parsing continues until the first non-hex character or to the end of the string. Otherwise, no more than <tt class="docutils literal"><span class="pre">maxLen</span></tt> characters are parsed starting from the <tt class="docutils literal"><span class="pre">start</span></tt> position.</p>
  476. <p>It does not check for overflow. If the value represented by the string is too big to fit into <tt class="docutils literal"><span class="pre">number</span></tt>, only the value of last fitting characters will be stored in <tt class="docutils literal"><span class="pre">number</span></tt> without producing an error.</p>
  477. <p><strong class="examples_text">Example:</strong></p>
  478. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  479. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;4E_69_ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">8</span>
  480. <span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
  481. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;X&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  482. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;#ABC&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  483. <span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
  484. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;0x_4E_69_ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  485. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="HexNumber">0xED'i8</span>
  486. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;0x_4E_69_ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  487. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="HexNumber">0x4E'i8</span>
  488. <span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
  489. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;0x_4E_69_ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8u</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  490. <span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
  491. <span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
  492. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;4E69ED4E69ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num64</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">12</span>
  493. <span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">86216859871725</span></pre>
  494. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L159" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  495. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L159" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  496. </dd>
  497. </div>
  498. <div id="parseHex,string,T,int,int">
  499. <dt><pre><span class="Keyword">proc</span> <a href="#parseHex%2Cstring%2CT%2Cint%2Cint"><span class="Identifier">parseHex</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">;</span> <span class="Identifier">maxLen</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  500. <span class="Identifier">noSideEffect</span>.}</pre></dt>
  501. <dd>
  502. <p>Parses a hexadecimal number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
  503. <p>Returns the number of the parsed characters or 0 in case of an error. If error, the value of <tt class="docutils literal"><span class="pre">number</span></tt> is not changed.</p>
  504. <p>If <tt class="docutils literal"><span class="pre">maxLen == 0</span></tt>, the parsing continues until the first non-hex character or to the end of the string. Otherwise, no more than <tt class="docutils literal"><span class="pre">maxLen</span></tt> characters are parsed starting from the <tt class="docutils literal"><span class="pre">start</span></tt> position.</p>
  505. <p>It does not check for overflow. If the value represented by the string is too big to fit into <tt class="docutils literal"><span class="pre">number</span></tt>, only the value of last fitting characters will be stored in <tt class="docutils literal"><span class="pre">number</span></tt> without producing an error.</p>
  506. <p><strong class="examples_text">Example:</strong></p>
  507. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  508. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;4E_69_ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">8</span>
  509. <span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
  510. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;X&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  511. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;#ABC&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  512. <span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
  513. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;0x_4E_69_ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  514. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="HexNumber">0xED'i8</span>
  515. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;0x_4E_69_ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  516. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="HexNumber">0x4E'i8</span>
  517. <span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
  518. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;0x_4E_69_ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8u</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  519. <span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
  520. <span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
  521. <span class="Identifier">doAssert</span> <span class="Identifier">parseHex</span><span class="Punctuation">(</span><span class="StringLit">&quot;4E69ED4E69ED&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num64</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">12</span>
  522. <span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">86216859871725</span></pre>
  523. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L811" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  524. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L811" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  525. </dd>
  526. </div>
  527. </div>
  528. <div id="parseIdent-procs-all">
  529. <div id="parseIdent,openArray[char]">
  530. <dt><pre><span class="Keyword">proc</span> <a href="#parseIdent%2CopenArray%5Bchar%5D"><span class="Identifier">parseIdent</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  531. <dd>
  532. Parses an identifier and returns it or an empty string in case of an error.
  533. <p><strong class="examples_text">Example:</strong></p>
  534. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello&quot;</span>
  535. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;ello&quot;</span>
  536. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;&quot;</span>
  537. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;World&quot;</span></pre>
  538. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L235" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  539. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L235" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  540. </dd>
  541. </div>
  542. <div id="parseIdent,openArray[char],string">
  543. <dt><pre><span class="Keyword">proc</span> <a href="#parseIdent%2CopenArray%5Bchar%5D%2Cstring"><span class="Identifier">parseIdent</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">ident</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  544. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  545. <dd>
  546. Parses an identifier and stores it in <tt class="docutils literal"><span class="pre">ident</span></tt>. Returns the number of the parsed characters or 0 in case of an error. If error, the value of <tt class="docutils literal"><span class="pre"><span class="Identifier">ident</span></span></tt> is not changed.
  547. <p><strong class="examples_text">Example:</strong></p>
  548. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  549. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
  550. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello&quot;</span>
  551. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  552. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;ello&quot;</span>
  553. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
  554. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;World&quot;</span></pre>
  555. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L214" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  556. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L214" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  557. </dd>
  558. </div>
  559. <div id="parseIdent,string,string,int">
  560. <dt><pre><span class="Keyword">proc</span> <a href="#parseIdent%2Cstring%2Cstring%2Cint"><span class="Identifier">parseIdent</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">ident</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  561. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  562. <dd>
  563. Parses an identifier and stores it in <tt class="docutils literal"><span class="pre">ident</span></tt>. Returns the number of the parsed characters or 0 in case of an error. If error, the value of <tt class="docutils literal"><span class="pre"><span class="Identifier">ident</span></span></tt> is not changed.
  564. <p><strong class="examples_text">Example:</strong></p>
  565. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  566. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
  567. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello&quot;</span>
  568. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  569. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;ello&quot;</span>
  570. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
  571. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;World&quot;</span></pre>
  572. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L844" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  573. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L844" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  574. </dd>
  575. </div>
  576. <div id="parseIdent,string,int">
  577. <dt><pre><span class="Keyword">proc</span> <a href="#parseIdent%2Cstring%2Cint"><span class="Identifier">parseIdent</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  578. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  579. <dd>
  580. Parses an identifier and returns it or an empty string in case of an error.
  581. <p><strong class="examples_text">Example:</strong></p>
  582. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello&quot;</span>
  583. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;ello&quot;</span>
  584. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;&quot;</span>
  585. <span class="Identifier">doAssert</span> <span class="Identifier">parseIdent</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">&quot;World&quot;</span></pre>
  586. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L858" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  587. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L858" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  588. </dd>
  589. </div>
  590. </div>
  591. <div id="parseInt-procs-all">
  592. <div id="parseInt,openArray[char],int">
  593. <dt><pre><span class="Keyword">proc</span> <a href="#parseInt%2CopenArray%5Bchar%5D%2Cint"><span class="Identifier">parseInt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  594. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;npuParseInt&quot;</span><span class="Other">,</span> </span><span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  595. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  596. <dd>
  597. Parses an integer and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. Result is the number of processed chars or 0 if there is no integer. <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> is raised if the parsed integer is out of the valid range.
  598. <p><strong class="examples_text">Example:</strong></p>
  599. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  600. <span class="Identifier">doAssert</span> <span class="Identifier">parseInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;-2024_05_02&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  601. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">20240502</span></pre>
  602. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L484" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  603. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L484" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  604. </dd>
  605. </div>
  606. <div id="parseInt,string,int,int">
  607. <dt><pre><span class="Keyword">proc</span> <a href="#parseInt%2Cstring%2Cint%2Cint"><span class="Identifier">parseInt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span>
  608. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  609. <dd>
  610. Parses an integer starting at <tt class="docutils literal"><span class="pre"><span class="Identifier">start</span></span></tt> and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. Result is the number of processed chars or 0 if there is no integer. <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> is raised if the parsed integer is out of the valid range.
  611. <p><strong class="examples_text">Example:</strong></p>
  612. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  613. <span class="Identifier">doAssert</span> <span class="Identifier">parseInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;-2024_05_02&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  614. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">20240502</span>
  615. <span class="Identifier">doAssert</span> <span class="Identifier">parseInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;-2024_05_02&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  616. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">502</span></pre>
  617. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1017" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  618. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1017" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  619. </dd>
  620. </div>
  621. </div>
  622. <div id="parseOct-procs-all">
  623. <div id="parseOct,openArray[char],T,int">
  624. <dt><pre><span class="Keyword">proc</span> <a href="#parseOct%2CopenArray%5Bchar%5D%2CT%2Cint"><span class="Identifier">parseOct</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">maxLen</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  625. <span class="Identifier">noSideEffect</span>.}</pre></dt>
  626. <dd>
  627. <p>Parses an octal number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
  628. <p>Returns the number of the parsed characters or 0 in case of an error. If error, the value of <tt class="docutils literal"><span class="pre">number</span></tt> is not changed.</p>
  629. <p>If <tt class="docutils literal"><span class="pre">maxLen == 0</span></tt>, the parsing continues until the first non-oct character or to the end of the string. Otherwise, no more than <tt class="docutils literal"><span class="pre">maxLen</span></tt> characters are parsed starting from the <tt class="docutils literal"><span class="pre">start</span></tt> position.</p>
  630. <p>It does not check for overflow. If the value represented by the string is too big to fit into <tt class="docutils literal"><span class="pre">number</span></tt>, only the value of last fitting characters will be stored in <tt class="docutils literal"><span class="pre">number</span></tt> without producing an error.</p>
  631. <p><strong class="examples_text">Example:</strong></p>
  632. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  633. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;0o23464755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">10</span>
  634. <span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
  635. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;8&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  636. <span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
  637. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;0o_1464_755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  638. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">19</span>
  639. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;0o_1464_755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
  640. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="DecNumber">102</span>
  641. <span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
  642. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;1464755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8u</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">7</span>
  643. <span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
  644. <span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
  645. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;2346475523464755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num64</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">16</span>
  646. <span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">86216859871725</span></pre>
  647. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L111" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  648. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L111" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  649. </dd>
  650. </div>
  651. <div id="parseOct,string,T,int,int">
  652. <dt><pre><span class="Keyword">proc</span> <a href="#parseOct%2Cstring%2CT%2Cint%2Cint"><span class="Identifier">parseOct</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">;</span> <span class="Identifier">maxLen</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  653. <span class="Identifier">noSideEffect</span>.}</pre></dt>
  654. <dd>
  655. <p>Parses an octal number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
  656. <p>Returns the number of the parsed characters or 0 in case of an error. If error, the value of <tt class="docutils literal"><span class="pre">number</span></tt> is not changed.</p>
  657. <p>If <tt class="docutils literal"><span class="pre">maxLen == 0</span></tt>, the parsing continues until the first non-oct character or to the end of the string. Otherwise, no more than <tt class="docutils literal"><span class="pre">maxLen</span></tt> characters are parsed starting from the <tt class="docutils literal"><span class="pre">start</span></tt> position.</p>
  658. <p>It does not check for overflow. If the value represented by the string is too big to fit into <tt class="docutils literal"><span class="pre">number</span></tt>, only the value of last fitting characters will be stored in <tt class="docutils literal"><span class="pre">number</span></tt> without producing an error.</p>
  659. <p><strong class="examples_text">Example:</strong></p>
  660. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
  661. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;0o23464755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">10</span>
  662. <span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
  663. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;8&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  664. <span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
  665. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;0o_1464_755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span>
  666. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">19</span>
  667. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;0o_1464_755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
  668. <span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="DecNumber">102</span>
  669. <span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
  670. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;1464755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num8u</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">7</span>
  671. <span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
  672. <span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
  673. <span class="Identifier">doAssert</span> <span class="Identifier">parseOct</span><span class="Punctuation">(</span><span class="StringLit">&quot;2346475523464755&quot;</span><span class="Punctuation">,</span> <span class="Identifier">num64</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">16</span>
  674. <span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">86216859871725</span></pre>
  675. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L779" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  676. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L779" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  677. </dd>
  678. </div>
  679. </div>
  680. <div id="parseSaturatedNatural-procs-all">
  681. <div id="parseSaturatedNatural,openArray[char],int">
  682. <dt><pre><span class="Keyword">proc</span> <a href="#parseSaturatedNatural%2CopenArray%5Bchar%5D%2Cint"><span class="Identifier">parseSaturatedNatural</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  683. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  684. <dd>
  685. Parses a natural number into <tt class="docutils literal"><span class="pre">b</span></tt>. This cannot raise an overflow error. <tt class="docutils literal"><span class="pre">high(int)</span></tt> is returned for an overflow. The number of processed character is returned. This is usually what you really want to use instead of <span id="parseint_1">parseInt</span>.
  686. <p><strong class="examples_text">Example:</strong></p>
  687. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span> <span class="Operator">=</span> <span class="DecNumber">0</span>
  688. <span class="Keyword">discard</span> <span class="Identifier">parseSaturatedNatural</span><span class="Punctuation">(</span><span class="StringLit">&quot;848&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span>
  689. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">848</span></pre>
  690. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L501" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  691. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L501" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  692. </dd>
  693. </div>
  694. <div id="parseSaturatedNatural,string,int,int">
  695. <dt><pre><span class="Keyword">proc</span> <a href="#parseSaturatedNatural%2Cstring%2Cint%2Cint"><span class="Identifier">parseSaturatedNatural</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  696. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  697. <dd>
  698. Parses a natural number into <tt class="docutils literal"><span class="pre">b</span></tt>. This cannot raise an overflow error. <tt class="docutils literal"><span class="pre">high(int)</span></tt> is returned for an overflow. The number of processed character is returned. This is usually what you really want to use instead of <span id="parseint_2">parseInt</span>.
  699. <p><strong class="examples_text">Example:</strong></p>
  700. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span> <span class="Operator">=</span> <span class="DecNumber">0</span>
  701. <span class="Keyword">discard</span> <span class="Identifier">parseSaturatedNatural</span><span class="Punctuation">(</span><span class="StringLit">&quot;848&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span>
  702. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">848</span></pre>
  703. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1030" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  704. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1030" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  705. </dd>
  706. </div>
  707. </div>
  708. <div id="parseSize-procs-all">
  709. <div id="parseSize,openArray[char],int64">
  710. <dt><pre><span class="Keyword">func</span> <a href="#parseSize%2CopenArray%5Bchar%5D%2Cint64"><span class="Identifier">parseSize</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#int64"><span class="Identifier">int64</span></a><span class="Other">;</span> <span class="Identifier">alwaysBin</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  711. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  712. <dd>
  713. <p>Parse a size qualified by binary or metric units into <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt>. This format is often called &quot;human readable&quot;. Result is the number of processed chars or 0 on parse errors and size is rounded to the nearest integer. Trailing garbage like &quot;/s&quot; in &quot;1k/s&quot; is allowed and detected by <tt class="docutils literal"><span class="pre"><span class="Identifier">result</span> <span class="Operator">&lt;</span> <span class="Identifier">s</span><span class="Operator">.</span><span class="Identifier">len</span></span></tt>.</p>
  714. <p>To simplify use, following non-rare wild conventions, and since fractional data like milli-bytes is so rare, unit matching is case-insensitive but for the 'i' distinguishing binary-metric from metric (which cannot be 'I').</p>
  715. <p>An optional trailing 'B|b' is ignored but processed. I.e., you must still know if units are bytes | bits or infer this fact via the case of s<sup><strong><a class="reference internal" href="#footnote-1">[1]</a></strong></sup> (if users can even be relied upon to use 'B' for byte and 'b' for bit or have that be s<sup><strong><a class="reference internal" href="#footnote-1">[1]</a></strong></sup>).</p>
  716. <p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">alwaysBin</span><span class="Operator">==</span><span class="Identifier">true</span></span></tt> then scales are always binary-metric, but e.g. &quot;KiB&quot; is still accepted for clarity. If the value would exceed the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">int64</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> saturates to <tt class="docutils literal"><span class="pre"><span class="Identifier">int64</span><span class="Operator">.</span><span class="Identifier">high</span></span></tt>. Supported metric prefix chars include k, m, g, t, p, e, z, y (but z &amp; y saturate unless the number is a small fraction).</p>
  717. <p><strong>See also:</strong></p>
  718. <ul class="simple"><li><a class="reference external" href="https://en.wikipedia.org/wiki/Binary_prefix">https://en.wikipedia.org/wiki/Binary_prefix</a></li>
  719. <li><a class="reference external" href="strutils.html">formatSize module</a> for formatting</li>
  720. </ul>
  721. <p><strong class="examples_text">Example:</strong></p>
  722. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">int64</span> <span class="Comment"># caller must still know if 'b' refers to bytes|bits</span>
  723. <span class="Identifier">doAssert</span> <span class="Identifier">parseSize</span><span class="Punctuation">(</span><span class="StringLit">&quot;10.5 MB&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">7</span>
  724. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">10_500_000</span> <span class="Comment"># decimal metric Mega prefix</span>
  725. <span class="Identifier">doAssert</span> <span class="Identifier">parseSize</span><span class="Punctuation">(</span><span class="StringLit">&quot;64 mib&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
  726. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">67108864</span> <span class="Comment"># 64 shl 20</span>
  727. <span class="Identifier">doAssert</span> <span class="Identifier">parseSize</span><span class="Punctuation">(</span><span class="StringLit">&quot;1G/h&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="Identifier">true</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span> <span class="Comment"># '/' stops parse</span>
  728. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">1073741824</span> <span class="Comment"># 1 shl 30, forced binary metric</span></pre>
  729. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L613" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  730. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L613" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  731. </dd>
  732. </div>
  733. </div>
  734. <div id="parseUInt-procs-all">
  735. <div id="parseUInt,openArray[char],uint">
  736. <dt><pre><span class="Keyword">proc</span> <a href="#parseUInt%2CopenArray%5Bchar%5D%2Cuint"><span class="Identifier">parseUInt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#uint"><span class="Identifier">uint</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  737. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;npuParseUInt&quot;</span><span class="Other">,</span> </span><span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  738. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  739. <dd>
  740. Parses an unsigned integer and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> is raised if the parsed integer is out of the valid range.
  741. <p><strong class="examples_text">Example:</strong></p>
  742. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">uint</span>
  743. <span class="Identifier">doAssert</span> <span class="Identifier">parseUInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;3450&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  744. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">3450</span>
  745. <span class="Identifier">doAssert</span> <span class="Identifier">parseUInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;3450&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  746. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">50</span></pre>
  747. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L567" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  748. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L567" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  749. </dd>
  750. </div>
  751. <div id="parseUInt,string,uint,int">
  752. <dt><pre><span class="Keyword">proc</span> <a href="#parseUInt%2Cstring%2Cuint%2Cint"><span class="Identifier">parseUInt</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">number</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#uint"><span class="Identifier">uint</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span>
  753. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  754. <dd>
  755. Parses an unsigned integer starting at <tt class="docutils literal"><span class="pre"><span class="Identifier">start</span></span></tt> and stores the value into <tt class="docutils literal"><span class="pre"><span class="Identifier">number</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> is raised if the parsed integer is out of the valid range.
  756. <p><strong class="examples_text">Example:</strong></p>
  757. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">uint</span>
  758. <span class="Identifier">doAssert</span> <span class="Identifier">parseUInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;3450&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  759. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">3450</span>
  760. <span class="Identifier">doAssert</span> <span class="Identifier">parseUInt</span><span class="Punctuation">(</span><span class="StringLit">&quot;3450&quot;</span><span class="Punctuation">,</span> <span class="Identifier">res</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  761. <span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">50</span></pre>
  762. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1055" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  763. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1055" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  764. </dd>
  765. </div>
  766. </div>
  767. <div id="parseUntil-procs-all">
  768. <div id="parseUntil,openArray[char],string,char">
  769. <dt><pre><span class="Keyword">proc</span> <a href="#parseUntil%2CopenArray%5Bchar%5D%2Cstring%2Cchar"><span class="Identifier">parseUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">token</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  770. <span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  771. <dd>
  772. Parses a token and stores it in <tt class="docutils literal"><span class="pre">token</span></tt>. Returns the number of the parsed characters or 0 in case of an error. A token consists of any character that is not the <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt> character.
  773. <p><strong class="examples_text">Example:</strong></p>
  774. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  775. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="CharLit">'W'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
  776. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
  777. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="CharLit">'o'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  778. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hell&quot;</span>
  779. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="CharLit">'o'</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  780. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;ll&quot;</span></pre>
  781. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L358" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  782. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L358" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  783. </dd>
  784. </div>
  785. <div id="parseUntil,openArray[char],string,set[char]">
  786. <dt><pre><span class="Keyword">proc</span> <a href="#parseUntil%2CopenArray%5Bchar%5D%2Cstring%2Cset%5Bchar%5D"><span class="Identifier">parseUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">token</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  787. <span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  788. <dd>
  789. Parses a token and stores it in <tt class="docutils literal"><span class="pre">token</span></tt>. Returns the number of the parsed characters or 0 in case of an error. A token consists of the characters notin <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt>.
  790. <p><strong class="examples_text">Example:</strong></p>
  791. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  792. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">o</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}) == 4</span>
  793. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hell&quot;</span>
  794. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}) == 6</span>
  795. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
  796. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}, 3) == 3</span>
  797. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;lo &quot;</span></pre>
  798. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L340" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  799. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L340" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  800. </dd>
  801. </div>
  802. <div id="parseUntil,openArray[char],string,string">
  803. <dt><pre><span class="Keyword">proc</span> <a href="#parseUntil%2CopenArray%5Bchar%5D%2Cstring%2Cstring"><span class="Identifier">parseUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">token</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  804. <span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  805. <dd>
  806. Parses a token and stores it in <tt class="docutils literal"><span class="pre">token</span></tt>. Returns the number of the parsed characters or 0 in case of an error. A token consists of any character that comes before the <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt> token.
  807. <p><strong class="examples_text">Example:</strong></p>
  808. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  809. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="StringLit">&quot;Wor&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
  810. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
  811. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="StringLit">&quot;Wor&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  812. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;llo &quot;</span></pre>
  813. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L376" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  814. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L376" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  815. </dd>
  816. </div>
  817. <div id="parseUntil,string,string,char,int">
  818. <dt><pre><span class="Keyword">proc</span> <a href="#parseUntil%2Cstring%2Cstring%2Cchar%2Cint"><span class="Identifier">parseUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">token</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  819. <span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  820. <dd>
  821. Parses a token and stores it in <tt class="docutils literal"><span class="pre">token</span></tt>. Returns the number of the parsed characters or 0 in case of an error. A token consists of any character that is not the <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt> character.
  822. <p><strong class="examples_text">Example:</strong></p>
  823. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  824. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="CharLit">'W'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
  825. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
  826. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="CharLit">'o'</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  827. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hell&quot;</span>
  828. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="CharLit">'o'</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  829. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;ll&quot;</span></pre>
  830. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L953" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  831. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L953" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  832. </dd>
  833. </div>
  834. <div id="parseUntil,string,string,set[char],int">
  835. <dt><pre><span class="Keyword">proc</span> <a href="#parseUntil%2Cstring%2Cstring%2Cset%5Bchar%5D%2Cint"><span class="Identifier">parseUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">token</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  836. <span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  837. <dd>
  838. Parses a token and stores it in <tt class="docutils literal"><span class="pre">token</span></tt>. Returns the number of the parsed characters or 0 in case of an error. A token consists of the characters notin <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt>.
  839. <p><strong class="examples_text">Example:</strong></p>
  840. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  841. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">o</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}) == 4</span>
  842. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hell&quot;</span>
  843. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}) == 6</span>
  844. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
  845. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}, 3) == 3</span>
  846. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;lo &quot;</span></pre>
  847. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L938" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  848. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L938" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  849. </dd>
  850. </div>
  851. <div id="parseUntil,string,string,string,int">
  852. <dt><pre><span class="Keyword">proc</span> <a href="#parseUntil%2Cstring%2Cstring%2Cstring%2Cint"><span class="Identifier">parseUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">token</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  853. <span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  854. <dd>
  855. Parses a token and stores it in <tt class="docutils literal"><span class="pre">token</span></tt>. Returns the number of the parsed characters or 0 in case of an error. A token consists of any character that comes before the <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt> token.
  856. <p><strong class="examples_text">Example:</strong></p>
  857. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  858. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="StringLit">&quot;Wor&quot;</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
  859. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
  860. <span class="Identifier">doAssert</span> <span class="Identifier">parseUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="StringLit">&quot;Wor&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  861. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;llo &quot;</span></pre>
  862. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L968" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  863. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L968" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  864. </dd>
  865. </div>
  866. </div>
  867. <div id="parseWhile-procs-all">
  868. <div id="parseWhile,openArray[char],string,set[char]">
  869. <dt><pre><span class="Keyword">proc</span> <a href="#parseWhile%2CopenArray%5Bchar%5D%2Cstring%2Cset%5Bchar%5D"><span class="Identifier">parseWhile</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">token</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">validChars</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  870. <span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  871. <dd>
  872. Parses a token and stores it in <tt class="docutils literal"><span class="pre">token</span></tt>. Returns the number of the parsed characters or 0 in case of an error. A token consists of the characters in <tt class="docutils literal"><span class="pre"><span class="Identifier">validChars</span></span></tt>.
  873. <p><strong class="examples_text">Example:</strong></p>
  874. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  875. <span class="Identifier">doAssert</span> <span class="Identifier">parseWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">o</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}, 0) == 0</span>
  876. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span><span class="Operator">.</span><span class="Identifier">len</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  877. <span class="Identifier">doAssert</span> <span class="Identifier">parseWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">o</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}, 6) == 3</span>
  878. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Wor&quot;</span></pre>
  879. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L402" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  880. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L402" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  881. </dd>
  882. </div>
  883. <div id="parseWhile,string,string,set[char],int">
  884. <dt><pre><span class="Keyword">proc</span> <a href="#parseWhile%2Cstring%2Cstring%2Cset%5Bchar%5D%2Cint"><span class="Identifier">parseWhile</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">token</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">validChars</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
  885. <span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  886. <dd>
  887. Parses a token and stores it in <tt class="docutils literal"><span class="pre">token</span></tt>. Returns the number of the parsed characters or 0 in case of an error. A token consists of the characters in <tt class="docutils literal"><span class="pre"><span class="Identifier">validChars</span></span></tt>.
  888. <p><strong class="examples_text">Example:</strong></p>
  889. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
  890. <span class="Identifier">doAssert</span> <span class="Identifier">parseWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">o</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}, 0) == 0</span>
  891. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span><span class="Operator">.</span><span class="Identifier">len</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  892. <span class="Identifier">doAssert</span> <span class="Identifier">parseWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Identifier">myToken</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">o</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}, 6) == 3</span>
  893. <span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Wor&quot;</span></pre>
  894. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L981" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  895. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L981" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  896. </dd>
  897. </div>
  898. </div>
  899. <div id="skip-procs-all">
  900. <div id="skip,openArray[char],openArray[char]">
  901. <dt><pre><span class="Keyword">proc</span> <a href="#skip%2CopenArray%5Bchar%5D%2CopenArray%5Bchar%5D"><span class="Identifier">skip</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">,</span> <span class="Identifier">token</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  902. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  903. <dd>
  904. Skips the <tt class="docutils literal"><span class="pre"><span class="Identifier">token</span></span></tt> starting at <tt class="docutils literal"><span class="pre">s[start]</span></tt>. Returns the length of <tt class="docutils literal"><span class="pre"><span class="Identifier">token</span></span></tt> or 0 if there was no <tt class="docutils literal"><span class="pre"><span class="Identifier">token</span></span></tt> at <tt class="docutils literal"><span class="pre">s[start]</span></tt>.
  905. <p><strong class="examples_text">Example:</strong></p>
  906. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;2019-01-22&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;2019&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  907. <span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;2019-01-22&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;19&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  908. <span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;2019-01-22&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;19&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  909. <span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;CAPlow&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;CAP&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
  910. <span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;CAPlow&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;cap&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span></pre>
  911. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L278" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  912. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L278" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  913. </dd>
  914. </div>
  915. <div id="skip,string,string,int">
  916. <dt><pre><span class="Keyword">proc</span> <a href="#skip%2Cstring%2Cstring%2Cint"><span class="Identifier">skip</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">,</span> <span class="Identifier">token</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  917. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  918. <dd>
  919. Skips the <tt class="docutils literal"><span class="pre"><span class="Identifier">token</span></span></tt> starting at <tt class="docutils literal"><span class="pre">s[start]</span></tt>. Returns the length of <tt class="docutils literal"><span class="pre"><span class="Identifier">token</span></span></tt> or 0 if there was no <tt class="docutils literal"><span class="pre"><span class="Identifier">token</span></span></tt> at <tt class="docutils literal"><span class="pre">s[start]</span></tt>.
  920. <p><strong class="examples_text">Example:</strong></p>
  921. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;2019-01-22&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;2019&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  922. <span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;2019-01-22&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;19&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  923. <span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;2019-01-22&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;19&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  924. <span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;CAPlow&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;CAP&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
  925. <span class="Identifier">doAssert</span> <span class="Identifier">skip</span><span class="Punctuation">(</span><span class="StringLit">&quot;CAPlow&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;cap&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span></pre>
  926. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L890" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  927. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L890" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  928. </dd>
  929. </div>
  930. </div>
  931. <div id="skipIgnoreCase-procs-all">
  932. <div id="skipIgnoreCase,openArray[char],openArray[char]">
  933. <dt><pre><span class="Keyword">proc</span> <a href="#skipIgnoreCase%2CopenArray%5Bchar%5D%2CopenArray%5Bchar%5D"><span class="Identifier">skipIgnoreCase</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">,</span> <span class="Identifier">token</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  934. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  935. <dd>
  936. Same as <tt class="docutils literal"><span class="pre"><span class="Identifier">skip</span></span></tt> but case is ignored for token matching.
  937. <p><strong class="examples_text">Example:</strong></p>
  938. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipIgnoreCase</span><span class="Punctuation">(</span><span class="StringLit">&quot;CAPlow&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;CAP&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
  939. <span class="Identifier">doAssert</span> <span class="Identifier">skipIgnoreCase</span><span class="Punctuation">(</span><span class="StringLit">&quot;CAPlow&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;cap&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span></pre>
  940. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L293" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  941. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L293" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  942. </dd>
  943. </div>
  944. <div id="skipIgnoreCase,string,string,int">
  945. <dt><pre><span class="Keyword">proc</span> <a href="#skipIgnoreCase%2Cstring%2Cstring%2Cint"><span class="Identifier">skipIgnoreCase</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">,</span> <span class="Identifier">token</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  946. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  947. <dd>
  948. Same as <tt class="docutils literal"><span class="pre"><span class="Identifier">skip</span></span></tt> but case is ignored for token matching.
  949. <p><strong class="examples_text">Example:</strong></p>
  950. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipIgnoreCase</span><span class="Punctuation">(</span><span class="StringLit">&quot;CAPlow&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;CAP&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
  951. <span class="Identifier">doAssert</span> <span class="Identifier">skipIgnoreCase</span><span class="Punctuation">(</span><span class="StringLit">&quot;CAPlow&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;cap&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span></pre>
  952. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L901" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  953. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L901" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  954. </dd>
  955. </div>
  956. </div>
  957. <div id="skipUntil-procs-all">
  958. <div id="skipUntil,openArray[char],char">
  959. <dt><pre><span class="Keyword">proc</span> <a href="#skipUntil%2CopenArray%5Bchar%5D%2Cchar"><span class="Identifier">skipUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  960. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  961. <dd>
  962. Skips all characters until the char <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt> is found or the end is reached. Returns number of characters skipped.
  963. <p><strong class="examples_text">Example:</strong></p>
  964. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'o'</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  965. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'o'</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  966. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'W'</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
  967. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'w'</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span></pre>
  968. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L314" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  969. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L314" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  970. </dd>
  971. </div>
  972. <div id="skipUntil,openArray[char],set[char]">
  973. <dt><pre><span class="Keyword">proc</span> <a href="#skipUntil%2CopenArray%5Bchar%5D%2Cset%5Bchar%5D"><span class="Identifier">skipUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  974. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  975. <dd>
  976. Skips all characters until one char from the set <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt> is found or the end is reached. Returns number of characters skipped.
  977. <p><strong class="examples_text">Example:</strong></p>
  978. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">e</span><span class="CharLit">'}, 0) == 1</span>
  979. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">'}, 0) == 6</span>
  980. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">d</span><span class="CharLit">'}, 0) == 6</span></pre>
  981. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L303" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  982. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L303" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  983. </dd>
  984. </div>
  985. <div id="skipUntil,string,char,int">
  986. <dt><pre><span class="Keyword">proc</span> <a href="#skipUntil%2Cstring%2Cchar%2Cint"><span class="Identifier">skipUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  987. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  988. <dd>
  989. Skips all characters until the char <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt> is found or the end is reached. Returns number of characters skipped.
  990. <p><strong class="examples_text">Example:</strong></p>
  991. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'o'</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  992. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'o'</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  993. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'W'</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
  994. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="CharLit">'w'</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">11</span></pre>
  995. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L918" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  996. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L918" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  997. </dd>
  998. </div>
  999. <div id="skipUntil,string,set[char],int">
  1000. <dt><pre><span class="Keyword">proc</span> <a href="#skipUntil%2Cstring%2Cset%5Bchar%5D%2Cint"><span class="Identifier">skipUntil</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">until</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span>
  1001. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1002. <dd>
  1003. Skips all characters until one char from the set <tt class="docutils literal"><span class="pre"><span class="Identifier">until</span></span></tt> is found or the end is reached. Returns number of characters skipped.
  1004. <p><strong class="examples_text">Example:</strong></p>
  1005. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">e</span><span class="CharLit">'}, 0) == 1</span>
  1006. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">'}, 0) == 6</span>
  1007. <span class="Identifier">doAssert</span> <span class="Identifier">skipUntil</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">d</span><span class="CharLit">'}, 0) == 6</span></pre>
  1008. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L908" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1009. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L908" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1010. </dd>
  1011. </div>
  1012. </div>
  1013. <div id="skipWhile-procs-all">
  1014. <div id="skipWhile,openArray[char],set[char]">
  1015. <dt><pre><span class="Keyword">proc</span> <a href="#skipWhile%2CopenArray%5Bchar%5D%2Cset%5Bchar%5D"><span class="Identifier">skipWhile</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">toSkip</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1016. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1017. <dd>
  1018. Skips all characters while one char from the set <tt class="docutils literal"><span class="pre"><span class="Identifier">toSkip</span></span></tt> is found. Returns number of characters skipped.
  1019. <p><strong class="examples_text">Example:</strong></p>
  1020. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">H</span><span class="CharLit">', '</span><span class="Identifier">e</span><span class="CharLit">'}) == 2</span>
  1021. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">e</span><span class="CharLit">'}) == 0</span>
  1022. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">o</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}, 6) == 3</span></pre>
  1023. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L326" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1024. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L326" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1025. </dd>
  1026. </div>
  1027. <div id="skipWhile,string,set[char],int">
  1028. <dt><pre><span class="Keyword">proc</span> <a href="#skipWhile%2Cstring%2Cset%5Bchar%5D%2Cint"><span class="Identifier">skipWhile</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">toSkip</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span>
  1029. <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1030. <dd>
  1031. Skips all characters while one char from the set <tt class="docutils literal"><span class="pre"><span class="Identifier">toSkip</span></span></tt> is found. Returns number of characters skipped.
  1032. <p><strong class="examples_text">Example:</strong></p>
  1033. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">H</span><span class="CharLit">', '</span><span class="Identifier">e</span><span class="CharLit">'}) == 2</span>
  1034. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">e</span><span class="CharLit">'}) == 0</span>
  1035. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhile</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">{</span><span class="Punctuation">'</span><span class="Identifier">W</span><span class="CharLit">', '</span><span class="Identifier">o</span><span class="CharLit">', '</span><span class="Identifier">r</span><span class="CharLit">'}, 6) == 3</span></pre>
  1036. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L929" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1037. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L929" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1038. </dd>
  1039. </div>
  1040. </div>
  1041. <div id="skipWhitespace-procs-all">
  1042. <div id="skipWhitespace,openArray[char]">
  1043. <dt><pre><span class="Keyword">proc</span> <a href="#skipWhitespace%2CopenArray%5Bchar%5D"><span class="Identifier">skipWhitespace</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1044. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1045. <dd>
  1046. Skips the whitespace starting at <tt class="docutils literal"><span class="pre">s[start]</span></tt>. Returns the number of skipped characters.
  1047. <p><strong class="examples_text">Example:</strong></p>
  1048. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipWhitespace</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  1049. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhitespace</span><span class="Punctuation">(</span><span class="StringLit">&quot; Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
  1050. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhitespace</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
  1051. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhitespace</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
  1052. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L267" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1053. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L267" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1054. </dd>
  1055. </div>
  1056. <div id="skipWhitespace,string,int">
  1057. <dt><pre><span class="Keyword">proc</span> <a href="#skipWhitespace%2Cstring%2Cint"><span class="Identifier">skipWhitespace</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">start</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1058. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1059. <dd>
  1060. Skips the whitespace starting at <tt class="docutils literal"><span class="pre">s[start]</span></tt>. Returns the number of skipped characters.
  1061. <p><strong class="examples_text">Example:</strong></p>
  1062. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">skipWhitespace</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  1063. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhitespace</span><span class="Punctuation">(</span><span class="StringLit">&quot; Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
  1064. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhitespace</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
  1065. <span class="Identifier">doAssert</span> <span class="Identifier">skipWhitespace</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello World&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
  1066. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L880" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1067. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L880" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1068. </dd>
  1069. </div>
  1070. </div>
  1071. </dl>
  1072. </div>
  1073. <div class="section" id="15">
  1074. <h1><a class="toc-backref" href="#15">Iterators</a></h1>
  1075. <dl class="item">
  1076. <div id="interpolatedFragments-iterators-all">
  1077. <div id="interpolatedFragments.i,openArray[char]">
  1078. <dt><pre><span class="Keyword">iterator</span> <a href="#interpolatedFragments.i%2CopenArray%5Bchar%5D"><span class="Identifier">interpolatedFragments</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span>
  1079. <span class="Identifier">kind</span><span class="Other">:</span> <a href="parseutils.html#InterpolatedKind"><span class="Identifier">InterpolatedKind</span></a><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  1080. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1081. <dd>
  1082. Tokenizes the string <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> into substrings for interpolation purposes.
  1083. <p><strong class="examples_text">Example:</strong></p>
  1084. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">outp</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Keyword">tuple</span><span class="Punctuation">[</span><span class="Identifier">kind</span><span class="Punctuation">:</span> <span class="Identifier">InterpolatedKind</span><span class="Punctuation">,</span> <span class="Identifier">value</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">]</span><span class="Punctuation">]</span>
  1085. <span class="Keyword">for</span> <span class="Identifier">k</span><span class="Punctuation">,</span> <span class="Identifier">v</span> <span class="Keyword">in</span> <span class="Identifier">interpolatedFragments</span><span class="Punctuation">(</span><span class="StringLit">&quot; $this is ${an example} $$&quot;</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
  1086. <span class="Identifier">outp</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Punctuation">(</span><span class="Identifier">k</span><span class="Punctuation">,</span> <span class="Identifier">v</span><span class="Punctuation">)</span>
  1087. <span class="Identifier">doAssert</span> <span class="Identifier">outp</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">ikStr</span><span class="Punctuation">,</span> <span class="StringLit">&quot; &quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1088. <span class="Punctuation">(</span><span class="Identifier">ikVar</span><span class="Punctuation">,</span> <span class="StringLit">&quot;this&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1089. <span class="Punctuation">(</span><span class="Identifier">ikStr</span><span class="Punctuation">,</span> <span class="StringLit">&quot; is &quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1090. <span class="Punctuation">(</span><span class="Identifier">ikExpr</span><span class="Punctuation">,</span> <span class="StringLit">&quot;an example&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1091. <span class="Punctuation">(</span><span class="Identifier">ikStr</span><span class="Punctuation">,</span> <span class="StringLit">&quot; &quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1092. <span class="Punctuation">(</span><span class="Identifier">ikDollar</span><span class="Punctuation">,</span> <span class="StringLit">&quot;$&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span></pre>
  1093. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L684" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1094. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L684" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1095. </dd>
  1096. </div>
  1097. <div id="interpolatedFragments.i,string">
  1098. <dt><pre><span class="Keyword">iterator</span> <a href="#interpolatedFragments.i%2Cstring"><span class="Identifier">interpolatedFragments</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">kind</span><span class="Other">:</span> <a href="parseutils.html#InterpolatedKind"><span class="Identifier">InterpolatedKind</span></a><span class="Other">,</span>
  1099. <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  1100. <dd>
  1101. Tokenizes the string <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> into substrings for interpolation purposes.
  1102. <p><strong class="examples_text">Example:</strong></p>
  1103. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">outp</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Keyword">tuple</span><span class="Punctuation">[</span><span class="Identifier">kind</span><span class="Punctuation">:</span> <span class="Identifier">InterpolatedKind</span><span class="Punctuation">,</span> <span class="Identifier">value</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">]</span><span class="Punctuation">]</span>
  1104. <span class="Keyword">for</span> <span class="Identifier">k</span><span class="Punctuation">,</span> <span class="Identifier">v</span> <span class="Keyword">in</span> <span class="Identifier">interpolatedFragments</span><span class="Punctuation">(</span><span class="StringLit">&quot; $this is ${an example} $$&quot;</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
  1105. <span class="Identifier">outp</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Punctuation">(</span><span class="Identifier">k</span><span class="Punctuation">,</span> <span class="Identifier">v</span><span class="Punctuation">)</span>
  1106. <span class="Identifier">doAssert</span> <span class="Identifier">outp</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">ikStr</span><span class="Punctuation">,</span> <span class="StringLit">&quot; &quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1107. <span class="Punctuation">(</span><span class="Identifier">ikVar</span><span class="Punctuation">,</span> <span class="StringLit">&quot;this&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1108. <span class="Punctuation">(</span><span class="Identifier">ikStr</span><span class="Punctuation">,</span> <span class="StringLit">&quot; is &quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1109. <span class="Punctuation">(</span><span class="Identifier">ikExpr</span><span class="Punctuation">,</span> <span class="StringLit">&quot;an example&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1110. <span class="Punctuation">(</span><span class="Identifier">ikStr</span><span class="Punctuation">,</span> <span class="StringLit">&quot; &quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
  1111. <span class="Punctuation">(</span><span class="Identifier">ikDollar</span><span class="Punctuation">,</span> <span class="StringLit">&quot;$&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span></pre>
  1112. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1087" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  1113. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1087" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  1114. </dd>
  1115. </div>
  1116. </div>
  1117. </dl>
  1118. </div>
  1119. </div>
  1120. </div>
  1121. <div class="twelve-columns footer">
  1122. <span class="nim-sprite"></span>
  1123. <br>
  1124. <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 08:35:55 UTC</small>
  1125. </div>
  1126. </div>
  1127. </div>
  1128. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  1129. </body>
  1130. </html>