Files
Nim/parseutils.html
github-actions[bot] de413ab6bb Deploy to GitHub pages
2025-12-25 20:14:24 +00:00

1306 lines
223 KiB
HTML

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>std/parseutils</title>
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- Favicon -->
<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=="/>
<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=">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
<!-- JS -->
<script type="text/javascript" src="dochack.js?v=2.3.1"></script>
</head>
<body>
<div class="document" id="documentId">
<div class="container">
<h1 class="title">std/parseutils</h1>
<div class="row">
<div class="three columns">
<div class="theme-select-wrapper">
<label for="theme-select">Theme:&nbsp;</label>
<select id="theme-select" onchange="setTheme(this.value)">
<option value="auto">🌗 Match OS</option>
<option value="dark">🌑 Dark</option>
<option value="light">🌕 Light</option>
</select>
</div>
<div id="global-links">
<ul class="simple-boot">
<li><a href="manual.html">Manual</a></li>
<li><a href="lib.html">Standard library</a></li>
<li> <a id="indexLink" href="theindex.html">Index</a></li>
<li><a href="compiler/theindex.html">Compiler docs</a></li>
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="search" id="searchInput"
oninput="search()" />
</div>
<ul class="simple simple-toc" id="toc-list">
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#InterpolatedKind" title="InterpolatedKind = enum
ikStr, ## ``str`` part of the interpolated string
ikDollar, ## escaped ``$`` part of the interpolated string
ikVar, ## ``var`` part of the interpolated string
ikExpr ## ``expr`` part of the interpolated string">InterpolatedKind</a></li>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">captureBetween
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseBiggestFloat
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseBiggestInt
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseBiggestUInt
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseBin
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseChar
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseFloat
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseHex
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseIdent
<li><a class="reference" href="#parseIdent%2CopenArray%5Bchar%5D" title="parseIdent(s: openArray[char]): string">parseIdent(s: openArray[char]): string</a></li>
<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>
<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>
<li><a class="reference" href="#parseIdent%2Cstring%2Cint" title="parseIdent(s: string; start = 0): string">parseIdent(s: string; start = 0): string</a></li>
</ul>
<ul class="simple nested-toc-section">parseInt
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseOct
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseSaturatedNatural
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseSize
<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>
</ul>
<ul class="simple nested-toc-section">parseUInt
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseUntil
<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>
<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>
<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>
<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>
<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>
<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>
</ul>
<ul class="simple nested-toc-section">parseWhile
<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>
<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>
</ul>
<ul class="simple nested-toc-section">skip
<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>
<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>
</ul>
<ul class="simple nested-toc-section">skipIgnoreCase
<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>
<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>
</ul>
<ul class="simple nested-toc-section">skipUntil
<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>
<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>
<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>
<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>
</ul>
<ul class="simple nested-toc-section">skipWhile
<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>
<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>
</ul>
<ul class="simple nested-toc-section">skipWhitespace
<li><a class="reference" href="#skipWhitespace%2CopenArray%5Bchar%5D" title="skipWhitespace(s: openArray[char]): int">skipWhitespace(s: openArray[char]): int</a></li>
<li><a class="reference" href="#skipWhitespace%2Cstring%2Cint" title="skipWhitespace(s: string; start = 0): int">skipWhitespace(s: string; start = 0): int</a></li>
</ul>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">interpolatedFragments
<li><a class="reference" href="#interpolatedFragments.i%2CopenArray%5Bchar%5D" title="interpolatedFragments(s: openArray[char]): tuple[kind: InterpolatedKind,
value: string]">interpolatedFragments(s: openArray[char]): tuple[kind: InterpolatedKind,
value: string]</a></li>
<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>
</ul>
</ul>
</details>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
<div id="tocRoot"></div>
<p class="module-desc"><p>This module contains helpers for parsing tokens, numbers, integers, floats, identifiers, etc.</p>
<p>To unpack raw bytes look at the <a class="reference external" href="streams.html">streams</a> module.</p>
<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>
<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>
<span class="Keyword">for</span> <span class="Identifier">log</span> <span class="Keyword">in</span> <span class="Identifier">logs</span><span class="Punctuation">:</span>
<span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<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>
<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>
<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>
<span class="Keyword">let</span>
<span class="Identifier">input1</span> <span class="Operator">=</span> <span class="StringLit">&quot;2019 school start&quot;</span>
<span class="Identifier">input2</span> <span class="Operator">=</span> <span class="StringLit">&quot;3 years back&quot;</span>
<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>
<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>
<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>
<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>
<p><strong>See also:</strong></p>
<ul class="simple"><li><a class="reference external" href="strutils.html">strutils module</a> for combined and identical parsing proc's</li>
<li><a class="reference external" href="json.html">json module</a> for a JSON parser</li>
<li><a class="reference external" href="parsecfg.html">parsecfg module</a> for a configuration file parser</li>
<li><a class="reference external" href="parsecsv.html">parsecsv module</a> for a simple CSV (comma separated value) parser</li>
<li><a class="reference external" href="parseopt.html">parseopt module</a> for a command line parser</li>
<li><a class="reference external" href="parsexml.html">parsexml module</a> for a XML / HTML parser</li>
<li><a class="reference external" href="lib.html#pure-libraries-parsers">other parsers</a> for other parsers</li>
</ul>
</p>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<div id="InterpolatedKind">
<dt><pre><a href="parseutils.html#InterpolatedKind"><span class="Identifier">InterpolatedKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
<span class="Identifier">ikStr</span><span class="Other">,</span> <span class="Comment">## ``str`` part of the interpolated string</span>
<span class="Identifier">ikDollar</span><span class="Other">,</span> <span class="Comment">## escaped ``$`` part of the interpolated string</span>
<span class="Identifier">ikVar</span><span class="Other">,</span> <span class="Comment">## ``var`` part of the interpolated string</span>
<span class="Identifier">ikExpr</span> <span class="Comment">## ``expr`` part of the interpolated string</span></pre></dt>
<dd>
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;
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L678" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L678" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</dl>
</div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<div id="captureBetween-procs-all">
<div id="captureBetween,openArray[char],char,char">
<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> {.
<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>
<dd>
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).
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L418" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L418" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="captureBetween,string,char,char,int">
<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> {.
<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>
<dd>
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).
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L996" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L996" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseBiggestFloat-procs-all">
<div id="parseBiggestFloat,openArray[char],BiggestFloat">
<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> {.
<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>
<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>
<dd>
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.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L588" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L588" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseBiggestFloat,string,BiggestFloat,int">
<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> {.
<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>
<dd>
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.
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1069" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1069" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseBiggestInt-procs-all">
<div id="parseBiggestInt,openArray[char],BiggestInt">
<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>
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">BiggestInt</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">9223372036854775807</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">20240509</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L466" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L466" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseBiggestInt,string,BiggestInt,int">
<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> {.
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">BiggestInt</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">9223372036854775807</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">20240509</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">502</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1005" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1005" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseBiggestUInt-procs-all">
<div id="parseBiggestUInt,openArray[char],BiggestUInt">
<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> {.
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">BiggestUInt</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">12</span>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L551" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L551" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseBiggestUInt,string,BiggestUInt,int">
<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> {.
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">BiggestUInt</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">12</span>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1045" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1045" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseBin-procs-all">
<div id="parseBin,openArray[char],T,int">
<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> {.
<span class="Identifier">noSideEffect</span>.}</pre></dt>
<dd>
<p>Parses a binary number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
<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>
<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>
<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>
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
<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>
<span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="BinNumber">0b1110_1101'i8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="BinNumber">0b0100_1110'i8</span>
<span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
<span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">336784608873</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L63" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L63" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseBin,string,T,int,int">
<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> {.
<span class="Identifier">noSideEffect</span>.}</pre></dt>
<dd>
<p>Parses a binary number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
<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>
<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>
<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>
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
<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>
<span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="BinNumber">0b1110_1101'i8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="BinNumber">0b0100_1110'i8</span>
<span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
<span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">336784608873</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L749" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L749" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseChar-procs-all">
<div id="parseChar,openArray[char],char">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">char</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="CharLit">'\0'</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="CharLit">'n'</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L251" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L251" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseChar,string,char,int">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">char</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="CharLit">'\0'</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="CharLit">'n'</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L870" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L870" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseFloat-procs-all">
<div id="parseFloat,openArray[char],float">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">float</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">32.0</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">32.57</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">57.00</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L594" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L594" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseFloat,string,float,int">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">float</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">32.0</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">32.57</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="FloatNumber">57.00</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1075" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1075" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseHex-procs-all">
<div id="parseHex,openArray[char],T,int">
<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> {.
<span class="Identifier">noSideEffect</span>.}</pre></dt>
<dd>
<p>Parses a hexadecimal number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
<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>
<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>
<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>
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
<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>
<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>
<span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="HexNumber">0xED'i8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="HexNumber">0x4E'i8</span>
<span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
<span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">86216859871725</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L159" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L159" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseHex,string,T,int,int">
<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> {.
<span class="Identifier">noSideEffect</span>.}</pre></dt>
<dd>
<p>Parses a hexadecimal number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
<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>
<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>
<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>
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
<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>
<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>
<span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="HexNumber">0xED'i8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="HexNumber">0x4E'i8</span>
<span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
<span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">86216859871725</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L813" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L813" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseIdent-procs-all">
<div id="parseIdent,openArray[char]">
<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>
<dd>
Parses an identifier and returns it or an empty string in case of an error.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L235" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L235" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseIdent,openArray[char],string">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello&quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;ello&quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;World&quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L214" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L214" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseIdent,string,string,int">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello&quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;ello&quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="StringLit">&quot;World&quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L846" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L846" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseIdent,string,int">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Parses an identifier and returns it or an empty string in case of an error.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L860" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L860" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseInt-procs-all">
<div id="parseInt,openArray[char],int">
<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>
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">20240502</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L484" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L484" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseInt,string,int,int">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">20240502</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">502</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1019" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1019" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseOct-procs-all">
<div id="parseOct,openArray[char],T,int">
<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> {.
<span class="Identifier">noSideEffect</span>.}</pre></dt>
<dd>
<p>Parses an octal number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
<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>
<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>
<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>
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
<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>
<span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">19</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="DecNumber">102</span>
<span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
<span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">86216859871725</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L111" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L111" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseOct,string,T,int,int">
<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> {.
<span class="Identifier">noSideEffect</span>.}</pre></dt>
<dd>
<p>Parses an octal number and stores its value in <tt class="docutils literal"><span class="pre">number</span></tt>.</p>
<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>
<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>
<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>
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">num</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num</span> <span class="Operator">==</span> <span class="DecNumber">5138925</span>
<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>
<span class="Keyword">var</span> <span class="Identifier">num8</span><span class="Punctuation">:</span> <span class="Identifier">int8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">19</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8</span> <span class="Operator">==</span> <span class="DecNumber">102</span>
<span class="Keyword">var</span> <span class="Identifier">num8u</span><span class="Punctuation">:</span> <span class="Identifier">uint8</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num8u</span> <span class="Operator">==</span> <span class="DecNumber">237</span>
<span class="Keyword">var</span> <span class="Identifier">num64</span><span class="Punctuation">:</span> <span class="Identifier">int64</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">num64</span> <span class="Operator">==</span> <span class="DecNumber">86216859871725</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L781" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L781" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseSaturatedNatural-procs-all">
<div id="parseSaturatedNatural,openArray[char],int">
<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>
<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>
<dd>
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>.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span> <span class="Operator">=</span> <span class="DecNumber">0</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">848</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L501" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L501" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseSaturatedNatural,string,int,int">
<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>
<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>
<dd>
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>.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span> <span class="Operator">=</span> <span class="DecNumber">0</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">848</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1032" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1032" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseSize-procs-all">
<div id="parseSize,openArray[char],int64">
<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> {.
<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>
<dd>
<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>
<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>
<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>
<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>
<p><strong>See also:</strong></p>
<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>
<li><a class="reference external" href="strutils.html">formatSize module</a> for formatting</li>
</ul>
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L615" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L615" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseUInt-procs-all">
<div id="parseUInt,openArray[char],uint">
<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>
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">uint</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">3450</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">50</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L569" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L569" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseUInt,string,uint,int">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">uint</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">3450</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="DecNumber">50</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1057" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1057" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseUntil-procs-all">
<div id="parseUntil,openArray[char],string,char">
<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> {.
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hell&quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;ll&quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L358" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L358" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseUntil,openArray[char],string,set[char]">
<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> {.
<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>
<dd>
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>.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hell&quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;lo &quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L340" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L340" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseUntil,openArray[char],string,string">
<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> {.
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;llo &quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L376" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L376" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseUntil,string,string,char,int">
<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> {.
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hell&quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;ll&quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L955" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L955" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseUntil,string,string,set[char],int">
<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> {.
<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>
<dd>
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>.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hell&quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;lo &quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L940" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L940" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseUntil,string,string,string,int">
<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> {.
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello &quot;</span>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;llo &quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L970" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L970" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="parseWhile-procs-all">
<div id="parseWhile,openArray[char],string,set[char]">
<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> {.
<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>
<dd>
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>.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<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>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Wor&quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L402" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L402" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="parseWhile,string,string,set[char],int">
<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> {.
<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>
<dd>
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>.
<p><strong class="examples_text">Example:</strong></p>
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">myToken</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
<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>
<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>
<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>
<span class="Identifier">doAssert</span> <span class="Identifier">myToken</span> <span class="Operator">==</span> <span class="StringLit">&quot;Wor&quot;</span></pre>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L983" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L983" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="skip-procs-all">
<div id="skip,openArray[char],openArray[char]">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
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>.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L278" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L278" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="skip,string,string,int">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
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>.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L892" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L892" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="skipIgnoreCase-procs-all">
<div id="skipIgnoreCase,openArray[char],openArray[char]">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Same as <tt class="docutils literal"><span class="pre"><span class="Identifier">skip</span></span></tt> but case is ignored for token matching.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L293" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L293" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="skipIgnoreCase,string,string,int">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Same as <tt class="docutils literal"><span class="pre"><span class="Identifier">skip</span></span></tt> but case is ignored for token matching.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L903" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L903" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="skipUntil-procs-all">
<div id="skipUntil,openArray[char],char">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L314" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L314" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="skipUntil,openArray[char],set[char]">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L303" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L303" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="skipUntil,string,char,int">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L920" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L920" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="skipUntil,string,set[char],int">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L910" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L910" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="skipWhile-procs-all">
<div id="skipWhile,openArray[char],set[char]">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L326" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L326" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="skipWhile,string,set[char],int">
<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>
<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>
<dd>
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.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L931" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L931" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
<div id="skipWhitespace-procs-all">
<div id="skipWhitespace,openArray[char]">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Skips the whitespace starting at <tt class="docutils literal"><span class="pre">s[start]</span></tt>. Returns the number of skipped characters.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L267" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L267" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="skipWhitespace,string,int">
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Skips the whitespace starting at <tt class="docutils literal"><span class="pre">s[start]</span></tt>. Returns the number of skipped characters.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L882" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L882" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
</dl>
</div>
<div class="section" id="15">
<h1><a class="toc-backref" href="#15">Iterators</a></h1>
<dl class="item">
<div id="interpolatedFragments-iterators-all">
<div id="interpolatedFragments.i,openArray[char]">
<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>
<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>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Tokenizes the string <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> into substrings for interpolation purposes.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L686" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L686" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
<div id="interpolatedFragments.i,string">
<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>
<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>
<dd>
Tokenizes the string <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> into substrings for interpolation purposes.
<p><strong class="examples_text">Example:</strong></p>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parseutils.nim#L1089" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parseutils.nim#L1089" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
</dd>
</div>
</div>
</dl>
</div>
</div>
</div>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br>
<small style="color: var(--hint);">Made with Nim. Generated: 2025-12-25 20:13:23 UTC</small>
</div>
</div>
</div>
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
</body>
</html>