parsesql.html 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>std/parsesql</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  14. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">std/parsesql</h1>
  24. <div class="row">
  25. <div class="three columns">
  26. <div class="theme-select-wrapper">
  27. <label for="theme-select">Theme:&nbsp;</label>
  28. <select id="theme-select" onchange="setTheme(this.value)">
  29. <option value="auto">🌗 Match OS</option>
  30. <option value="dark">🌑 Dark</option>
  31. <option value="light">🌕 Light</option>
  32. </select>
  33. </div>
  34. <div id="global-links">
  35. <ul class="simple-boot">
  36. <li><a href="manual.html">Manual</a></li>
  37. <li><a href="lib.html">Standard library</a></li>
  38. <li> <a id="indexLink" href="theindex.html">Index</a></li>
  39. <li><a href="compiler/theindex.html">Compiler docs</a></li>
  40. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  41. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  42. </ul>
  43. </div>
  44. <div id="searchInputDiv">
  45. Search: <input type="search" id="searchInput"
  46. oninput="search()" />
  47. </div>
  48. <ul class="simple simple-toc" id="toc-list">
  49. <li>
  50. <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
  51. </li>
  52. <li>
  53. <details open>
  54. <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
  55. <ul class="simple simple-toc-section">
  56. <li><a class="reference" href="#SqlLexer" title="SqlLexer = object of BaseLexer">SqlLexer</a></li>
  57. <li><a class="reference" href="#SqlNode" title="SqlNode = ref SqlNodeObj">SqlNode</a></li>
  58. <li><a class="reference" href="#SqlNodeKind" title="SqlNodeKind = enum
  59. nkNone, nkIdent, nkQuotedIdent, nkStringLit, nkBitStringLit, nkHexStringLit,
  60. nkIntegerLit, nkNumericLit, nkPrimaryKey, nkForeignKey, nkNotNull, nkNull,
  61. nkStmtList, nkDot, nkDotDot, nkPrefix, nkInfix, nkCall, nkPrGroup,
  62. nkColumnReference, nkReferences, nkDefault, nkCheck, nkConstraint, nkUnique,
  63. nkIdentity, nkColumnDef, ## name, datatype, constraints
  64. nkInsert, nkUpdate, nkDelete, nkSelect, nkSelectDistinct, nkSelectColumns,
  65. nkSelectPair, nkAsgn, nkFrom, nkFromItemPair, nkJoin, nkNaturalJoin, nkUsing,
  66. nkGroup, nkLimit, nkOffset, nkHaving, nkOrder, nkDesc, nkUnion, nkIntersect,
  67. nkExcept, nkColumnList, nkValueList, nkWhere, nkCreateTable,
  68. nkCreateTableIfNotExists, nkCreateType, nkCreateTypeIfNotExists,
  69. nkCreateIndex, nkCreateIndexIfNotExists, nkEnumDef">SqlNodeKind</a></li>
  70. <li><a class="reference" href="#SqlNodeObj" title="SqlNodeObj = object
  71. case kind*: SqlNodeKind ## kind of syntax tree
  72. of LiteralNodes:
  73. strVal*: string ## AST leaf: the identifier, numeric literal
  74. ## string literal, etc.
  75. else:
  76. sons*: seq[SqlNode] ## the node's children">SqlNodeObj</a></li>
  77. <li><a class="reference" href="#SqlParseError" title="SqlParseError = object of ValueError">SqlParseError</a></li>
  78. <li><a class="reference" href="#SqlParser" title="SqlParser = object of SqlLexer
  79. ## Determines whether type parameters (e.g., sizes in types like VARCHAR(255)) are included in the SQL AST.">SqlParser</a></li>
  80. </ul>
  81. </details>
  82. </li>
  83. <li>
  84. <details open>
  85. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  86. <ul class="simple simple-toc-section">
  87. <ul class="simple nested-toc-section">$
  88. <li><a class="reference" href="#%24%2CSqlNode" title="`$`(n: SqlNode): string">`$`(n: SqlNode): string</a></li>
  89. </ul>
  90. <ul class="simple nested-toc-section">[]
  91. <li><a class="reference" href="#%5B%5D%2CSqlNode%2CBackwardsIndex" title="`[]`(n: SqlNode; i: BackwardsIndex): SqlNode">`[]`(n: SqlNode; i: BackwardsIndex): SqlNode</a></li>
  92. <li><a class="reference" href="#%5B%5D%2CSqlNode%2Cint" title="`[]`(n: SqlNode; i: int): SqlNode">`[]`(n: SqlNode; i: int): SqlNode</a></li>
  93. </ul>
  94. <ul class="simple nested-toc-section">add
  95. <li><a class="reference" href="#add%2CSqlNode%2CSqlNode" title="add(father, n: SqlNode)">add(father, n: SqlNode)</a></li>
  96. </ul>
  97. <ul class="simple nested-toc-section">len
  98. <li><a class="reference" href="#len%2CSqlNode" title="len(n: SqlNode): int">len(n: SqlNode): int</a></li>
  99. </ul>
  100. <ul class="simple nested-toc-section">newNode
  101. <li><a class="reference" href="#newNode%2CSqlNodeKind" title="newNode(k: SqlNodeKind): SqlNode">newNode(k: SqlNodeKind): SqlNode</a></li>
  102. <li><a class="reference" href="#newNode%2CSqlNodeKind%2Cstring" title="newNode(k: SqlNodeKind; s: string): SqlNode">newNode(k: SqlNodeKind; s: string): SqlNode</a></li>
  103. <li><a class="reference" href="#newNode%2CSqlNodeKind%2Cseq%5BSqlNode%5D" title="newNode(k: SqlNodeKind; sons: seq[SqlNode]): SqlNode">newNode(k: SqlNodeKind; sons: seq[SqlNode]): SqlNode</a></li>
  104. </ul>
  105. <ul class="simple nested-toc-section">parseSql
  106. <li><a class="reference" href="#parseSql%2CStream%2Cstring" title="parseSql(input: Stream; filename: string; considerTypeParams = false): SqlNode">parseSql(input: Stream; filename: string; considerTypeParams = false): SqlNode</a></li>
  107. <li><a class="reference" href="#parseSql%2Cstring%2Cstring" title="parseSql(input: string; filename = &quot;&quot;; considerTypeParams = false): SqlNode">parseSql(input: string; filename = &quot;&quot;; considerTypeParams = false): SqlNode</a></li>
  108. </ul>
  109. <ul class="simple nested-toc-section">renderSql
  110. <li><a class="reference" href="#renderSql%2CSqlNode" title="renderSql(n: SqlNode; upperCase = false): string">renderSql(n: SqlNode; upperCase = false): string</a></li>
  111. </ul>
  112. <ul class="simple nested-toc-section">treeRepr
  113. <li><a class="reference" href="#treeRepr%2CSqlNode" title="treeRepr(s: SqlNode): string">treeRepr(s: SqlNode): string</a></li>
  114. </ul>
  115. </ul>
  116. </details>
  117. </li>
  118. </ul>
  119. </div>
  120. <div class="nine columns" id="content">
  121. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  122. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  123. <div id="tocRoot"></div>
  124. <p class="module-desc"><p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">parsesql</span></span></tt> module implements a high performance SQL file parser. It parses PostgreSQL syntax and the SQL ANSI standard.</p>
  125. <p>Unstable API.</p>
  126. </p>
  127. <div class="section" id="6">
  128. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  129. <dl class="item">
  130. <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="lexbase.html">lexbase</a>, <a class="reference external" href="decode_helpers.html">decode_helpers</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="streams.html">streams</a>
  131. </dl>
  132. </div>
  133. <div class="section" id="7">
  134. <h1><a class="toc-backref" href="#7">Types</a></h1>
  135. <dl class="item">
  136. <div id="SqlLexer">
  137. <dt><pre><a href="parsesql.html#SqlLexer"><span class="Identifier">SqlLexer</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="lexbase.html#BaseLexer"><span class="Identifier">BaseLexer</span></a></pre></dt>
  138. <dd>
  139. the parser object.
  140. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L50" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  141. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L50" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  142. </dd>
  143. </div>
  144. <div id="SqlNode">
  145. <dt><pre><a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <a href="parsesql.html#SqlNodeObj"><span class="Identifier">SqlNodeObj</span></a></pre></dt>
  146. <dd>
  147. an SQL abstract syntax tree node
  148. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L541" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  149. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L541" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  150. </dd>
  151. </div>
  152. <div id="SqlNodeKind">
  153. <dt><pre><a href="parsesql.html#SqlNodeKind"><span class="Identifier">SqlNodeKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
  154. <span class="Identifier">nkNone</span><span class="Other">,</span> <span class="Identifier">nkIdent</span><span class="Other">,</span> <span class="Identifier">nkQuotedIdent</span><span class="Other">,</span> <span class="Identifier">nkStringLit</span><span class="Other">,</span> <span class="Identifier">nkBitStringLit</span><span class="Other">,</span> <span class="Identifier">nkHexStringLit</span><span class="Other">,</span>
  155. <span class="Identifier">nkIntegerLit</span><span class="Other">,</span> <span class="Identifier">nkNumericLit</span><span class="Other">,</span> <span class="Identifier">nkPrimaryKey</span><span class="Other">,</span> <span class="Identifier">nkForeignKey</span><span class="Other">,</span> <span class="Identifier">nkNotNull</span><span class="Other">,</span> <span class="Identifier">nkNull</span><span class="Other">,</span>
  156. <span class="Identifier">nkStmtList</span><span class="Other">,</span> <span class="Identifier">nkDot</span><span class="Other">,</span> <span class="Identifier">nkDotDot</span><span class="Other">,</span> <span class="Identifier">nkPrefix</span><span class="Other">,</span> <span class="Identifier">nkInfix</span><span class="Other">,</span> <span class="Identifier">nkCall</span><span class="Other">,</span> <span class="Identifier">nkPrGroup</span><span class="Other">,</span>
  157. <span class="Identifier">nkColumnReference</span><span class="Other">,</span> <span class="Identifier">nkReferences</span><span class="Other">,</span> <span class="Identifier">nkDefault</span><span class="Other">,</span> <span class="Identifier">nkCheck</span><span class="Other">,</span> <span class="Identifier">nkConstraint</span><span class="Other">,</span> <span class="Identifier">nkUnique</span><span class="Other">,</span>
  158. <span class="Identifier">nkIdentity</span><span class="Other">,</span> <span class="Identifier">nkColumnDef</span><span class="Other">,</span> <span class="Comment">## name, datatype, constraints</span>
  159. <span class="Identifier">nkInsert</span><span class="Other">,</span> <span class="Identifier">nkUpdate</span><span class="Other">,</span> <span class="Identifier">nkDelete</span><span class="Other">,</span> <span class="Identifier">nkSelect</span><span class="Other">,</span> <span class="Identifier">nkSelectDistinct</span><span class="Other">,</span> <span class="Identifier">nkSelectColumns</span><span class="Other">,</span>
  160. <span class="Identifier">nkSelectPair</span><span class="Other">,</span> <span class="Identifier">nkAsgn</span><span class="Other">,</span> <span class="Identifier">nkFrom</span><span class="Other">,</span> <span class="Identifier">nkFromItemPair</span><span class="Other">,</span> <span class="Identifier">nkJoin</span><span class="Other">,</span> <span class="Identifier">nkNaturalJoin</span><span class="Other">,</span> <span class="Identifier">nkUsing</span><span class="Other">,</span>
  161. <span class="Identifier">nkGroup</span><span class="Other">,</span> <span class="Identifier">nkLimit</span><span class="Other">,</span> <span class="Identifier">nkOffset</span><span class="Other">,</span> <span class="Identifier">nkHaving</span><span class="Other">,</span> <span class="Identifier">nkOrder</span><span class="Other">,</span> <span class="Identifier">nkDesc</span><span class="Other">,</span> <span class="Identifier">nkUnion</span><span class="Other">,</span> <span class="Identifier">nkIntersect</span><span class="Other">,</span>
  162. <span class="Identifier">nkExcept</span><span class="Other">,</span> <span class="Identifier">nkColumnList</span><span class="Other">,</span> <span class="Identifier">nkValueList</span><span class="Other">,</span> <span class="Identifier">nkWhere</span><span class="Other">,</span> <span class="Identifier">nkCreateTable</span><span class="Other">,</span>
  163. <span class="Identifier">nkCreateTableIfNotExists</span><span class="Other">,</span> <span class="Identifier">nkCreateType</span><span class="Other">,</span> <span class="Identifier">nkCreateTypeIfNotExists</span><span class="Other">,</span>
  164. <span class="Identifier">nkCreateIndex</span><span class="Other">,</span> <span class="Identifier">nkCreateIndexIfNotExists</span><span class="Other">,</span> <span class="Identifier">nkEnumDef</span></pre></dt>
  165. <dd>
  166. kind of SQL abstract syntax tree
  167. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L471" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  168. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L471" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  169. </dd>
  170. </div>
  171. <div id="SqlNodeObj">
  172. <dt><pre><a href="parsesql.html#SqlNodeObj"><span class="Identifier">SqlNodeObj</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
  173. <span class="Keyword">case</span> <span class="Identifier">kind</span><span class="Operator">*</span><span class="Other">:</span> <a href="parsesql.html#SqlNodeKind"><span class="Identifier">SqlNodeKind</span></a> <span class="Comment">## kind of syntax tree</span>
  174. <span class="Keyword">of</span> <span class="Identifier">LiteralNodes</span><span class="Other">:</span>
  175. <span class="Identifier">strVal</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Comment">## AST leaf: the identifier, numeric literal</span>
  176. <span class="Comment">## string literal, etc.</span>
  177. <span class="Keyword">else</span><span class="Other">:</span>
  178. <span class="Identifier">sons</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a><span class="Other">]</span> <span class="Comment">## the node's children</span></pre></dt>
  179. <dd>
  180. an SQL abstract syntax tree node
  181. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L542" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  182. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L542" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  183. </dd>
  184. </div>
  185. <div id="SqlParseError">
  186. <dt><pre><a href="parsesql.html#SqlParseError"><span class="Identifier">SqlParseError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="exceptions.html#ValueError"><span class="Identifier">ValueError</span></a></pre></dt>
  187. <dd>
  188. Invalid SQL encountered
  189. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L540" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  190. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L540" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  191. </dd>
  192. </div>
  193. <div id="SqlParser">
  194. <dt><pre><a href="parsesql.html#SqlParser"><span class="Identifier">SqlParser</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="parsesql.html#SqlLexer"><span class="Identifier">SqlLexer</span></a>
  195. <span class="Comment">## Determines whether type parameters (e.g., sizes in types like VARCHAR(255)) are included in the SQL AST.</span></pre></dt>
  196. <dd>
  197. SQL parser object
  198. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L550" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  199. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L550" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  200. </dd>
  201. </div>
  202. </dl>
  203. </div>
  204. <div class="section" id="12">
  205. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  206. <dl class="item">
  207. <div id="$-procs-all">
  208. <div id="$,SqlNode">
  209. <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CSqlNode"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a><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="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
  210. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  211. <dd>
  212. an alias for <tt class="docutils literal"><span class="pre"><span class="Identifier">renderSql</span></span></tt>.
  213. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L1539" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  214. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L1539" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  215. </dd>
  216. </div>
  217. </div>
  218. <div id="[]-procs-all">
  219. <div id="[],SqlNode,BackwardsIndex">
  220. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CSqlNode%2CBackwardsIndex"><span class="Identifier">`[]`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#BackwardsIndex"><span class="Identifier">BackwardsIndex</span></a><span class="Other">)</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</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>
  221. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  222. <dd>
  223. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L579" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  224. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L579" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  225. </dd>
  226. </div>
  227. <div id="[],SqlNode,int">
  228. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CSqlNode%2Cint"><span class="Identifier">`[]`</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</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>
  229. <dd>
  230. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L578" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  231. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L578" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  232. </dd>
  233. </div>
  234. </div>
  235. <div id="add-procs-all">
  236. <div id="add,SqlNode,SqlNode">
  237. <dt><pre><span class="Keyword">proc</span> <a href="#add%2CSqlNode%2CSqlNode"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">father</span><span class="Other">,</span> <span class="Identifier">n</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</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="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>
  238. <dd>
  239. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L581" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  240. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L581" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  241. </dd>
  242. </div>
  243. </div>
  244. <div id="len-procs-all">
  245. <div id="len,SqlNode">
  246. <dt><pre><span class="Keyword">proc</span> <a href="#len%2CSqlNode"><span class="Identifier">len</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</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>
  247. <dd>
  248. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L572" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  249. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L572" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  250. </dd>
  251. </div>
  252. </div>
  253. <div id="newNode-procs-all">
  254. <div id="newNode,SqlNodeKind">
  255. <dt><pre><span class="Keyword">proc</span> <a href="#newNode%2CSqlNodeKind"><span class="Identifier">newNode</span></a><span class="Other">(</span><span class="Identifier">k</span><span class="Other">:</span> <a href="parsesql.html#SqlNodeKind"><span class="Identifier">SqlNodeKind</span></a><span class="Other">)</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</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>
  256. <dd>
  257. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L554" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  258. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L554" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  259. </dd>
  260. </div>
  261. <div id="newNode,SqlNodeKind,string">
  262. <dt><pre><span class="Keyword">proc</span> <a href="#newNode%2CSqlNodeKind%2Cstring"><span class="Identifier">newNode</span></a><span class="Other">(</span><span class="Identifier">k</span><span class="Other">:</span> <a href="parsesql.html#SqlNodeKind"><span class="Identifier">SqlNodeKind</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> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</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>
  263. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  264. <dd>
  265. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L564" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  266. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L564" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  267. </dd>
  268. </div>
  269. <div id="newNode,SqlNodeKind,seq[SqlNode]">
  270. <dt><pre><span class="Keyword">proc</span> <a href="#newNode%2CSqlNodeKind%2Cseq%5BSqlNode%5D"><span class="Identifier">newNode</span></a><span class="Other">(</span><span class="Identifier">k</span><span class="Other">:</span> <a href="parsesql.html#SqlNodeKind"><span class="Identifier">SqlNodeKind</span></a><span class="Other">;</span> <span class="Identifier">sons</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</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>
  271. <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>
  272. <dd>
  273. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L568" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  274. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L568" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  275. </dd>
  276. </div>
  277. </div>
  278. <div id="parseSql-procs-all">
  279. <div id="parseSql,Stream,string">
  280. <dt><pre><span class="Keyword">proc</span> <a href="#parseSql%2CStream%2Cstring"><span class="Identifier">parseSql</span></a><span class="Other">(</span><span class="Identifier">input</span><span class="Other">:</span> <a href="streams.html#Stream"><span class="Identifier">Stream</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">considerTypeParams</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</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>
  281. <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">SqlParseError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
  282. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</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>
  283. <dd>
  284. parses the SQL from <tt class="docutils literal"><span class="pre"><span class="Identifier">input</span></span></tt> into an AST and returns the AST. <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> is only used for error messages. Syntax errors raise an <tt class="docutils literal"><span class="pre"><span class="Identifier">SqlParseError</span></span></tt> exception.
  285. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L1573" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  286. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L1573" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  287. </dd>
  288. </div>
  289. <div id="parseSql,string,string">
  290. <dt><pre><span class="Keyword">proc</span> <a href="#parseSql%2Cstring%2Cstring"><span class="Identifier">parseSql</span></a><span class="Other">(</span><span class="Identifier">input</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">filename</span> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">;</span> <span class="Identifier">considerTypeParams</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a> {.
  291. <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">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">SqlParseError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
  292. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</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>
  293. <dd>
  294. parses the SQL from <tt class="docutils literal"><span class="pre"><span class="Identifier">input</span></span></tt> into an AST and returns the AST. <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> is only used for error messages. Syntax errors raise an <tt class="docutils literal"><span class="pre"><span class="Identifier">SqlParseError</span></span></tt> exception.
  295. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L1584" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  296. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L1584" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  297. </dd>
  298. </div>
  299. </div>
  300. <div id="renderSql-procs-all">
  301. <div id="renderSql,SqlNode">
  302. <dt><pre><span class="Keyword">proc</span> <a href="#renderSql%2CSqlNode"><span class="Identifier">renderSql</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a><span class="Other">;</span> <span class="Identifier">upperCase</span> <span class="Other">=</span> <span class="Identifier">false</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="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
  303. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</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>
  304. <dd>
  305. Converts an SQL abstract syntax tree to its string representation.
  306. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L1533" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  307. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L1533" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  308. </dd>
  309. </div>
  310. </div>
  311. <div id="treeRepr-procs-all">
  312. <div id="treeRepr,SqlNode">
  313. <dt><pre><span class="Keyword">proc</span> <a href="#treeRepr%2CSqlNode"><span class="Identifier">treeRepr</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="parsesql.html#SqlNode"><span class="Identifier">SqlNode</span></a><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>
  314. <dd>
  315. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsesql.nim#L1555" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  316. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsesql.nim#L1555" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  317. </dd>
  318. </div>
  319. </div>
  320. </dl>
  321. </div>
  322. </div>
  323. </div>
  324. <div class="twelve-columns footer">
  325. <span class="nim-sprite"></span>
  326. <br>
  327. <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 13:28:10 UTC</small>
  328. </div>
  329. </div>
  330. </div>
  331. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  332. </body>
  333. </html>