OSDN Git Service

8aafab745593c9ed51373c747937a3aa9ea7e7db
[joypy/Thun.git] / docs / sphinx_docs / _build / html / parser.html
1
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5 <html xmlns="http://www.w3.org/1999/xhtml">
6   <head>
7     <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
8     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9     <title>Parsing Text into Joy Expressions &#8212; Thun 0.3.0 documentation</title>
10     <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
11     <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
12     <script type="text/javascript" src="_static/documentation_options.js"></script>
13     <script type="text/javascript" src="_static/jquery.js"></script>
14     <script type="text/javascript" src="_static/underscore.js"></script>
15     <script type="text/javascript" src="_static/doctools.js"></script>
16     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
17     <link rel="index" title="Index" href="genindex.html" />
18     <link rel="search" title="Search" href="search.html" />
19     <link rel="next" title="Tracing Joy Execution" href="pretty.html" />
20     <link rel="prev" title="Stack or Quote or Sequence or List…" href="stack.html" />
21    
22   <link rel="stylesheet" href="_static/custom.css" type="text/css" />
23   
24   
25   <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
26
27   </head><body>
28   
29
30     <div class="document">
31       <div class="documentwrapper">
32         <div class="bodywrapper">
33           <div class="body" role="main">
34             
35   <div class="section" id="parsing-text-into-joy-expressions">
36 <h1>Parsing Text into Joy Expressions<a class="headerlink" href="#parsing-text-into-joy-expressions" title="Permalink to this headline">¶</a></h1>
37 <p>TODO: example…</p>
38 <div class="section" id="module-joy.parser">
39 <span id="joy-parser"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.parser</span></code><a class="headerlink" href="#module-joy.parser" title="Permalink to this headline">¶</a></h2>
40 <p>This module exports a single function for converting text to a joy
41 expression as well as a single Symbol class and a single Exception type.</p>
42 <p>The Symbol string class is used by the interpreter to recognize literals
43 by the fact that they are not Symbol objects.</p>
44 <p>A crude grammar:</p>
45 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">joy</span> <span class="o">=</span> <span class="n">term</span><span class="o">*</span>
46 <span class="n">term</span> <span class="o">=</span> <span class="nb">int</span> <span class="o">|</span> <span class="nb">float</span> <span class="o">|</span> <span class="n">string</span> <span class="o">|</span> <span class="s1">&#39;[&#39;</span> <span class="n">joy</span> <span class="s1">&#39;]&#39;</span> <span class="o">|</span> <span class="n">symbol</span>
47 </pre></div>
48 </div>
49 <p>A Joy expression is a sequence of zero or more terms.  A term is a
50 literal value (integer, float, string, or Joy expression) or a function
51 symbol.  Function symbols are unquoted strings and cannot contain square
52 brackets.   Terms must be separated by blanks, which can be omitted
53 around square brackets.</p>
54 <dl class="exception">
55 <dt id="joy.parser.ParseError">
56 <em class="property">exception </em><code class="descclassname">joy.parser.</code><code class="descname">ParseError</code><a class="reference internal" href="_modules/joy/parser.html#ParseError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.parser.ParseError" title="Permalink to this definition">¶</a></dt>
57 <dd><p>Raised when there is a error while parsing text.</p>
58 </dd></dl>
59
60 <dl class="class">
61 <dt id="joy.parser.Symbol">
62 <em class="property">class </em><code class="descclassname">joy.parser.</code><code class="descname">Symbol</code><a class="reference internal" href="_modules/joy/parser.html#Symbol"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.parser.Symbol" title="Permalink to this definition">¶</a></dt>
63 <dd><p>A string class that represents Joy function names.</p>
64 </dd></dl>
65
66 <dl class="function">
67 <dt id="joy.parser.text_to_expression">
68 <code class="descclassname">joy.parser.</code><code class="descname">text_to_expression</code><span class="sig-paren">(</span><em>text</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/parser.html#text_to_expression"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#joy.parser.text_to_expression" title="Permalink to this definition">¶</a></dt>
69 <dd><p>Convert a string to a Joy expression.</p>
70 <p>When supplied with a string this function returns a Python datastructure
71 that represents the Joy datastructure described by the text expression.
72 Any unbalanced square brackets will raise a ParseError.</p>
73 <table class="docutils field-list" frame="void" rules="none">
74 <col class="field-name" />
75 <col class="field-body" />
76 <tbody valign="top">
77 <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>text</strong> (<em>str</em>) – Text to convert.</td>
78 </tr>
79 <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">stack</td>
80 </tr>
81 <tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><a class="reference internal" href="#joy.parser.ParseError" title="joy.parser.ParseError"><strong>ParseError</strong></a> – if the parse fails.</td>
82 </tr>
83 </tbody>
84 </table>
85 </dd></dl>
86
87 </div>
88 <div class="section" id="parser-internals">
89 <h2>Parser Internals<a class="headerlink" href="#parser-internals" title="Permalink to this headline">¶</a></h2>
90 <p>TODO: Document things like the regular expressions used for tokenizing, and the re.Scanner, etc…</p>
91 </div>
92 </div>
93
94
95           </div>
96         </div>
97       </div>
98       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
99         <div class="sphinxsidebarwrapper">
100   <h3><a href="index.html">Table Of Contents</a></h3>
101   <ul>
102 <li><a class="reference internal" href="#">Parsing Text into Joy Expressions</a><ul>
103 <li><a class="reference internal" href="#module-joy.parser"><code class="docutils literal notranslate"><span class="pre">joy.parser</span></code></a></li>
104 <li><a class="reference internal" href="#parser-internals">Parser Internals</a></li>
105 </ul>
106 </li>
107 </ul>
108 <div class="relations">
109 <h3>Related Topics</h3>
110 <ul>
111   <li><a href="index.html">Documentation overview</a><ul>
112       <li>Previous: <a href="stack.html" title="previous chapter">Stack or Quote or Sequence or List…</a></li>
113       <li>Next: <a href="pretty.html" title="next chapter">Tracing Joy Execution</a></li>
114   </ul></li>
115 </ul>
116 </div>
117   <div role="note" aria-label="source link">
118     <h3>This Page</h3>
119     <ul class="this-page-menu">
120       <li><a href="_sources/parser.rst.txt"
121             rel="nofollow">Show Source</a></li>
122     </ul>
123    </div>
124 <div id="searchbox" style="display: none" role="search">
125   <h3>Quick search</h3>
126     <div class="searchformwrapper">
127     <form class="search" action="search.html" method="get">
128       <input type="text" name="q" />
129       <input type="submit" value="Go" />
130       <input type="hidden" name="check_keywords" value="yes" />
131       <input type="hidden" name="area" value="default" />
132     </form>
133     </div>
134 </div>
135 <script type="text/javascript">$('#searchbox').show(0);</script>
136         </div>
137       </div>
138       <div class="clearer"></div>
139     </div>
140     <div class="footer" role="contentinfo">
141 <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
142 <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" />
143 </a>
144 <br />
145 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Thun Documentation</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="https://joypy.osdn.io/" property="cc:attributionName" rel="cc:attributionURL">Simon Forman</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.<br />Based on a work at <a xmlns:dct="http://purl.org/dc/terms/" href="https://osdn.net/projects/joypy/" rel="dct:source">https://osdn.net/projects/joypy/</a>.
146       Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.7.3.
147     </div>
148
149   </body>
150 </html>