index.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta name="generator" content="rustdoc">
  7. <meta name="description" content="API documentation for the Rust `synom` crate.">
  8. <meta name="keywords" content="rust, rustlang, rust-lang, synom">
  9. <title>synom - Rust</title>
  10. <link rel="stylesheet" type="text/css" href="../normalize.css">
  11. <link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle">
  12. <link rel="stylesheet" type="text/css" href="../dark.css">
  13. <link rel="stylesheet" type="text/css" href="../main.css" id="themeStyle">
  14. <script src="../storage.js"></script>
  15. </head>
  16. <body class="rustdoc mod">
  17. <!--[if lte IE 8]>
  18. <div class="warning">
  19. This old browser is unsupported and will most likely display funky
  20. things.
  21. </div>
  22. <![endif]-->
  23. <nav class="sidebar">
  24. <div class="sidebar-menu">&#9776;</div>
  25. <p class='location'>Crate synom</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#macros">Macros</a></li><li><a href="#enums">Enums</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'synom', ty: 'mod', relpath: '../'};</script></div>
  26. </nav>
  27. <div class="theme-picker">
  28. <button id="theme-picker" aria-label="Pick another theme!">
  29. <img src="../brush.svg" width="18" alt="Pick another theme!">
  30. </button>
  31. <div id="theme-choices"></div>
  32. </div>
  33. <script src="../theme.js"></script>
  34. <nav class="sub">
  35. <form class="search-form js-only">
  36. <div class="search-container">
  37. <input class="search-input" name="search"
  38. autocomplete="off"
  39. placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
  40. type="search">
  41. </div>
  42. </form>
  43. </nav>
  44. <section id='main' class="content">
  45. <h1 class='fqn'><span class='in-band'>Crate <a class="mod" href=''>synom</a></span><span class='out-of-band'><span id='render-detail'>
  46. <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
  47. [<span class='inner'>&#x2212;</span>]
  48. </a>
  49. </span><a class='srclink' href='../src/synom/lib.rs.html#1-1225' title='goto source code'>[src]</a></span></h1>
  50. <div class='docblock'><p>Adapted from <a href="https://github.com/Geal/nom"><code>nom</code></a> by removing the
  51. <code>IResult::Incomplete</code> variant which:</p>
  52. <ul>
  53. <li>we don't need,</li>
  54. <li>is an unintuitive footgun when working with non-streaming use cases, and</li>
  55. <li>more than doubles compilation time.</li>
  56. </ul>
  57. <h2 id="whitespace-handling-strategy" class="section-header"><a href="#whitespace-handling-strategy">Whitespace handling strategy</a></h2>
  58. <p>As (sy)nom is a parser combinator library, the parsers provided here and
  59. that you implement yourself are all made up of successively more primitive
  60. parsers, eventually culminating in a small number of fundamental parsers
  61. that are implemented in Rust. Among these are <code>punct!</code> and <code>keyword!</code>.</p>
  62. <p>All synom fundamental parsers (those not combined out of other parsers)
  63. should be written to skip over leading whitespace in their input. This way,
  64. as long as every parser eventually boils down to some combination of
  65. fundamental parsers, we get correct whitespace handling at all levels for
  66. free.</p>
  67. <p>For our use case, this strategy is a huge improvement in usability,
  68. correctness, and compile time over nom's <code>ws!</code> strategy.</p>
  69. </div><h2 id='macros' class='section-header'><a href="#macros">Macros</a></h2>
  70. <table>
  71. <tr class=' module-item'>
  72. <td><a class="macro" href="macro.alt.html"
  73. title='macro synom::alt'>alt</a></td>
  74. <td class='docblock-short'>
  75. <p>Run a series of parsers, returning the result of the first one which
  76. succeeds.</p>
  77. </td>
  78. </tr>
  79. <tr class=' module-item'>
  80. <td><a class="macro" href="macro.call.html"
  81. title='macro synom::call'>call</a></td>
  82. <td class='docblock-short'>
  83. <p>Invoke the given parser function with the passed in arguments.</p>
  84. </td>
  85. </tr>
  86. <tr class=' module-item'>
  87. <td><a class="macro" href="macro.cond.html"
  88. title='macro synom::cond'>cond</a></td>
  89. <td class='docblock-short'>
  90. <p>Conditionally execute the given parser.</p>
  91. </td>
  92. </tr>
  93. <tr class=' module-item'>
  94. <td><a class="macro" href="macro.cond_reduce.html"
  95. title='macro synom::cond_reduce'>cond_reduce</a></td>
  96. <td class='docblock-short'>
  97. <p>Fail to parse if condition is false, otherwise parse the given parser.</p>
  98. </td>
  99. </tr>
  100. <tr class=' module-item'>
  101. <td><a class="macro" href="macro.delimited.html"
  102. title='macro synom::delimited'>delimited</a></td>
  103. <td class='docblock-short'>
  104. <p>Value surrounded by a pair of delimiters.</p>
  105. </td>
  106. </tr>
  107. <tr class=' module-item'>
  108. <td><a class="macro" href="macro.do_parse.html"
  109. title='macro synom::do_parse'>do_parse</a></td>
  110. <td class='docblock-short'>
  111. <p>Run a series of parsers, one after another, optionally assigning the results
  112. a name. Fail if any of the parsers fails.</p>
  113. </td>
  114. </tr>
  115. <tr class=' module-item'>
  116. <td><a class="macro" href="macro.epsilon.html"
  117. title='macro synom::epsilon'>epsilon</a></td>
  118. <td class='docblock-short'>
  119. <p>Parses nothing and always succeeds.</p>
  120. </td>
  121. </tr>
  122. <tr class=' module-item'>
  123. <td><a class="macro" href="macro.keyword.html"
  124. title='macro synom::keyword'>keyword</a></td>
  125. <td class='docblock-short'>
  126. <p>Parse a keyword like &quot;fn&quot; or &quot;struct&quot;.</p>
  127. </td>
  128. </tr>
  129. <tr class=' module-item'>
  130. <td><a class="macro" href="macro.many0.html"
  131. title='macro synom::many0'>many0</a></td>
  132. <td class='docblock-short'>
  133. <p>Parse zero or more values using the given parser.</p>
  134. </td>
  135. </tr>
  136. <tr class=' module-item'>
  137. <td><a class="macro" href="macro.map.html"
  138. title='macro synom::map'>map</a></td>
  139. <td class='docblock-short'>
  140. <p>Transform the result of a parser by applying a function or closure.</p>
  141. </td>
  142. </tr>
  143. <tr class=' module-item'>
  144. <td><a class="macro" href="macro.named.html"
  145. title='macro synom::named'>named</a></td>
  146. <td class='docblock-short'>
  147. <p>Define a function from a parser combination.</p>
  148. </td>
  149. </tr>
  150. <tr class=' module-item'>
  151. <td><a class="macro" href="macro.not.html"
  152. title='macro synom::not'>not</a></td>
  153. <td class='docblock-short'>
  154. <p>Parses successfully if the given parser fails to parse. Does not consume any
  155. of the input.</p>
  156. </td>
  157. </tr>
  158. <tr class=' module-item'>
  159. <td><a class="macro" href="macro.opt_vec.html"
  160. title='macro synom::opt_vec'>opt_vec</a></td>
  161. <td class='docblock-short'>
  162. <p>Turn a failed parse into an empty vector. The argument parser must itself
  163. return a vector.</p>
  164. </td>
  165. </tr>
  166. <tr class=' module-item'>
  167. <td><a class="macro" href="macro.option.html"
  168. title='macro synom::option'>option</a></td>
  169. <td class='docblock-short'>
  170. <p>Turn a failed parse into <code>None</code> and a successful parse into <code>Some</code>.</p>
  171. </td>
  172. </tr>
  173. <tr class=' module-item'>
  174. <td><a class="macro" href="macro.peek.html"
  175. title='macro synom::peek'>peek</a></td>
  176. <td class='docblock-short'>
  177. <p>Parse a value without consuming it from the input data.</p>
  178. </td>
  179. </tr>
  180. <tr class=' module-item'>
  181. <td><a class="macro" href="macro.preceded.html"
  182. title='macro synom::preceded'>preceded</a></td>
  183. <td class='docblock-short'>
  184. <p>Parse two things, returning the value of the second.</p>
  185. </td>
  186. </tr>
  187. <tr class=' module-item'>
  188. <td><a class="macro" href="macro.punct.html"
  189. title='macro synom::punct'>punct</a></td>
  190. <td class='docblock-short'>
  191. <p>Parse a piece of punctuation like &quot;+&quot; or &quot;+=&quot;.</p>
  192. </td>
  193. </tr>
  194. <tr class=' module-item'>
  195. <td><a class="macro" href="macro.separated_list.html"
  196. title='macro synom::separated_list'>separated_list</a></td>
  197. <td class='docblock-short'>
  198. <p>Zero or more values separated by some separator. Does not allow a trailing
  199. seperator.</p>
  200. </td>
  201. </tr>
  202. <tr class=' module-item'>
  203. <td><a class="macro" href="macro.separated_nonempty_list.html"
  204. title='macro synom::separated_nonempty_list'>separated_nonempty_list</a></td>
  205. <td class='docblock-short'>
  206. <p>One or more values separated by some separator. Does not allow a trailing
  207. separator.</p>
  208. </td>
  209. </tr>
  210. <tr class=' module-item'>
  211. <td><a class="macro" href="macro.switch.html"
  212. title='macro synom::switch'>switch</a></td>
  213. <td class='docblock-short'>
  214. <p>Pattern-match the result of a parser to select which other parser to run.</p>
  215. </td>
  216. </tr>
  217. <tr class=' module-item'>
  218. <td><a class="macro" href="macro.tag.html"
  219. title='macro synom::tag'>tag</a></td>
  220. <td class='docblock-short'>
  221. <p>Parse the given string from exactly the current position in the input. You
  222. almost always want <code>punct!</code> or <code>keyword!</code> instead of this.</p>
  223. </td>
  224. </tr>
  225. <tr class=' module-item'>
  226. <td><a class="macro" href="macro.take_until.html"
  227. title='macro synom::take_until'>take_until</a></td>
  228. <td class='docblock-short'>
  229. <p>Parse the part of the input up to but not including the given string. Fail
  230. to parse if the given string is not present in the input.</p>
  231. </td>
  232. </tr>
  233. <tr class=' module-item'>
  234. <td><a class="macro" href="macro.terminated.html"
  235. title='macro synom::terminated'>terminated</a></td>
  236. <td class='docblock-short'>
  237. <p>Parse two things, returning the value of the first.</p>
  238. </td>
  239. </tr>
  240. <tr class=' module-item'>
  241. <td><a class="macro" href="macro.terminated_list.html"
  242. title='macro synom::terminated_list'>terminated_list</a></td>
  243. <td class='docblock-short'>
  244. <p>Zero or more values separated by some separator. A trailing separator is
  245. allowed.</p>
  246. </td>
  247. </tr>
  248. <tr class=' module-item'>
  249. <td><a class="macro" href="macro.tuple.html"
  250. title='macro synom::tuple'>tuple</a></td>
  251. <td class='docblock-short'>
  252. <p>Run a series of parsers and produce all of the results in a tuple.</p>
  253. </td>
  254. </tr>
  255. <tr class=' module-item'>
  256. <td><a class="macro" href="macro.value.html"
  257. title='macro synom::value'>value</a></td>
  258. <td class='docblock-short'>
  259. <p>Produce the given value without parsing anything. Useful as an argument to
  260. <code>switch!</code>.</p>
  261. </td>
  262. </tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
  263. <table>
  264. <tr class=' module-item'>
  265. <td><a class="enum" href="enum.IResult.html"
  266. title='enum synom::IResult'>IResult</a></td>
  267. <td class='docblock-short'>
  268. <p>The result of a parser.</p>
  269. </td>
  270. </tr></table></section>
  271. <section id='search' class="content hidden"></section>
  272. <section class="footer"></section>
  273. <aside id="help" class="hidden">
  274. <div>
  275. <h1 class="hidden">Help</h1>
  276. <div class="shortcuts">
  277. <h2>Keyboard Shortcuts</h2>
  278. <dl>
  279. <dt><kbd>?</kbd></dt>
  280. <dd>Show this help dialog</dd>
  281. <dt><kbd>S</kbd></dt>
  282. <dd>Focus the search field</dd>
  283. <dt><kbd>↑</kbd></dt>
  284. <dd>Move up in search results</dd>
  285. <dt><kbd>↓</kbd></dt>
  286. <dd>Move down in search results</dd>
  287. <dt><kbd>↹</kbd></dt>
  288. <dd>Switch tab</dd>
  289. <dt><kbd>&#9166;</kbd></dt>
  290. <dd>Go to active search result</dd>
  291. <dt><kbd>+</kbd></dt>
  292. <dd>Expand all sections</dd>
  293. <dt><kbd>-</kbd></dt>
  294. <dd>Collapse all sections</dd>
  295. </dl>
  296. </div>
  297. <div class="infos">
  298. <h2>Search Tricks</h2>
  299. <p>
  300. Prefix searches with a type followed by a colon (e.g.
  301. <code>fn:</code>) to restrict the search to a given type.
  302. </p>
  303. <p>
  304. Accepted types are: <code>fn</code>, <code>mod</code>,
  305. <code>struct</code>, <code>enum</code>,
  306. <code>trait</code>, <code>type</code>, <code>macro</code>,
  307. and <code>const</code>.
  308. </p>
  309. <p>
  310. Search functions by type signature (e.g.
  311. <code>vec -> usize</code> or <code>* -> vec</code>)
  312. </p>
  313. </div>
  314. </div>
  315. </aside>
  316. <script>
  317. window.rootPath = "../";
  318. window.currentCrate = "synom";
  319. </script>
  320. <script src="../main.js"></script>
  321. <script defer src="../search-index.js"></script>
  322. </body>
  323. </html>