OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/joypy/Thun
[joypy/Thun.git] / docs / sphinx_docs / _build / html / pretty.html
1
2 <!DOCTYPE html>
3
4 <html>
5   <head>
6     <meta charset="utf-8" />
7     <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
8
9     <title>Tracing Joy Execution &#8212; Thun 0.4.1 documentation</title>
10     <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
11     <link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
12     <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
13     <script src="_static/jquery.js"></script>
14     <script src="_static/underscore.js"></script>
15     <script src="_static/doctools.js"></script>
16     <link rel="index" title="Index" href="genindex.html" />
17     <link rel="search" title="Search" href="search.html" />
18     <link rel="next" title="Function Reference" href="library.html" />
19     <link rel="prev" title="Parsing Text into Joy Expressions" href="parser.html" />
20    
21   <link rel="stylesheet" href="_static/custom.css" type="text/css" />
22   
23   
24   <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
25
26   </head><body>
27   
28
29     <div class="document">
30       <div class="documentwrapper">
31         <div class="bodywrapper">
32           
33
34           <div class="body" role="main">
35             
36   <section id="tracing-joy-execution">
37 <h1>Tracing Joy Execution<a class="headerlink" href="#tracing-joy-execution" title="Permalink to this headline">¶</a></h1>
38 <section id="module-joy.utils.pretty_print">
39 <span id="joy-utils-pretty-print"></span><h2><code class="docutils literal notranslate"><span class="pre">joy.utils.pretty_print</span></code><a class="headerlink" href="#module-joy.utils.pretty_print" title="Permalink to this headline">¶</a></h2>
40 <p>Pretty printing support, e.g.:</p>
41 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span>Joy? [23 18 * 99 +] trace
42        • 23 18 mul 99 add
43     23 • 18 mul 99 add
44  23 18 • mul 99 add
45    414 • 99 add
46 414 99 • add
47    513 • 
48
49 513 &lt;-top
50
51 joy? 
52 </pre></div>
53 </div>
54 <p>On each line the stack is printed with the top to the left, then a
55 bullet symbol,``•<a href="#id1"><span class="problematic" id="id2">``</span></a>, to represent the current locus of processing, then
56 the pending expression to the right.</p>
57 <dl class="py class">
58 <dt class="sig sig-object py" id="joy.utils.pretty_print.TracePrinter">
59 <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">joy.utils.pretty_print.</span></span><span class="sig-name descname"><span class="pre">TracePrinter</span></span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter" title="Permalink to this definition">¶</a></dt>
60 <dd><p>This is what does the formatting.  You instantiate it and pass the <code class="docutils literal notranslate"><span class="pre">viewer()</span></code>
61 method to the <a class="reference internal" href="joy.html#joy.joy.joy" title="joy.joy.joy"><code class="xref py py-func docutils literal notranslate"><span class="pre">joy.joy.joy()</span></code></a> function, then print it to see the
62 trace.</p>
63 <dl class="py method">
64 <dt class="sig sig-object py" id="joy.utils.pretty_print.TracePrinter.go">
65 <span class="sig-name descname"><span class="pre">go</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter.go"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter.go" title="Permalink to this definition">¶</a></dt>
66 <dd><p>Return a list of strings, one for each entry in the history, prefixed
67 with enough spaces to align all the interpreter dots.</p>
68 <p>This method is called internally by the <code class="docutils literal notranslate"><span class="pre">__str__()</span></code> method.</p>
69 <dl class="field-list simple">
70 <dt class="field-odd">Return type</dt>
71 <dd class="field-odd"><p>list(str)</p>
72 </dd>
73 </dl>
74 </dd></dl>
75
76 <dl class="py method">
77 <dt class="sig sig-object py" id="joy.utils.pretty_print.TracePrinter.viewer">
78 <span class="sig-name descname"><span class="pre">viewer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#TracePrinter.viewer"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.pretty_print.TracePrinter.viewer" title="Permalink to this definition">¶</a></dt>
79 <dd><p>Record the current stack and expression in the TracePrinter’s history.
80 Pass this method as the <code class="docutils literal notranslate"><span class="pre">viewer</span></code> argument to the <a class="reference internal" href="joy.html#joy.joy.joy" title="joy.joy.joy"><code class="xref py py-func docutils literal notranslate"><span class="pre">joy.joy.joy()</span></code></a> function.</p>
81 <dl class="field-list simple">
82 <dt class="field-odd">Parameters</dt>
83 <dd class="field-odd"><ul class="simple">
84 <li><p><strong>quote</strong> (<em>stack</em>) – A stack.</p></li>
85 <li><p><strong>expression</strong> (<em>stack</em>) – A stack.</p></li>
86 </ul>
87 </dd>
88 </dl>
89 </dd></dl>
90
91 </dd></dl>
92
93 <dl class="py function">
94 <dt class="sig sig-object py" id="joy.utils.pretty_print.trace">
95 <span class="sig-prename descclassname"><span class="pre">joy.utils.pretty_print.</span></span><span class="sig-name descname"><span class="pre">trace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stack</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">expression</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dictionary</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/joy/utils/pretty_print.html#trace"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#joy.utils.pretty_print.trace" title="Permalink to this definition">¶</a></dt>
96 <dd><p>Evaluate a Joy expression on a stack and print a trace.</p>
97 <p>This function is just like the <cite>i</cite> combinator but it also prints a
98 trace of the evaluation</p>
99 <dl class="field-list simple">
100 <dt class="field-odd">Parameters</dt>
101 <dd class="field-odd"><ul class="simple">
102 <li><p><strong>stack</strong> (<em>stack</em>) – The stack.</p></li>
103 <li><p><strong>expression</strong> (<em>stack</em>) – The expression to evaluate.</p></li>
104 <li><p><strong>dictionary</strong> (<em>dict</em>) – A <code class="docutils literal notranslate"><span class="pre">dict</span></code> mapping names to Joy functions.</p></li>
105 </ul>
106 </dd>
107 <dt class="field-even">Return type</dt>
108 <dd class="field-even"><p>(stack, (), dictionary)</p>
109 </dd>
110 </dl>
111 </dd></dl>
112
113 </section>
114 </section>
115
116
117           </div>
118           
119         </div>
120       </div>
121       <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
122         <div class="sphinxsidebarwrapper">
123 <h1 class="logo"><a href="index.html">Thun</a></h1>
124
125
126
127
128
129
130
131
132 <h3>Navigation</h3>
133 <ul class="current">
134 <li class="toctree-l1"><a class="reference internal" href="notebooks/Intro.html">Thun: Joy in Python</a></li>
135 <li class="toctree-l1"><a class="reference internal" href="joy.html">Joy Interpreter</a></li>
136 <li class="toctree-l1"><a class="reference internal" href="stack.html">Stack or Quote or Sequence or List…</a></li>
137 <li class="toctree-l1"><a class="reference internal" href="parser.html">Parsing Text into Joy Expressions</a></li>
138 <li class="toctree-l1 current"><a class="current reference internal" href="#">Tracing Joy Execution</a><ul>
139 <li class="toctree-l2"><a class="reference internal" href="#module-joy.utils.pretty_print"><code class="docutils literal notranslate"><span class="pre">joy.utils.pretty_print</span></code></a></li>
140 </ul>
141 </li>
142 <li class="toctree-l1"><a class="reference internal" href="library.html">Function Reference</a></li>
143 <li class="toctree-l1"><a class="reference internal" href="lib.html">Functions Grouped by, er, Function with Examples</a></li>
144 <li class="toctree-l1"><a class="reference internal" href="types.html">Type Inference of Joy Expressions</a></li>
145 <li class="toctree-l1"><a class="reference internal" href="notebooks/index.html">Essays about Programming in Joy</a></li>
146 </ul>
147
148 <div class="relations">
149 <h3>Related Topics</h3>
150 <ul>
151   <li><a href="index.html">Documentation overview</a><ul>
152       <li>Previous: <a href="parser.html" title="previous chapter">Parsing Text into Joy Expressions</a></li>
153       <li>Next: <a href="library.html" title="next chapter">Function Reference</a></li>
154   </ul></li>
155 </ul>
156 </div>
157 <div id="searchbox" style="display: none" role="search">
158   <h3 id="searchlabel">Quick search</h3>
159     <div class="searchformwrapper">
160     <form class="search" action="search.html" method="get">
161       <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
162       <input type="submit" value="Go" />
163     </form>
164     </div>
165 </div>
166 <script>$('#searchbox').show(0);</script>
167
168
169
170
171
172
173
174
175         </div>
176       </div>
177       <div class="clearer"></div>
178     </div>
179     <div class="footer" role="contentinfo">
180 <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">
181 <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" />
182 </a>
183 <br />
184 <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>.
185       Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.0.
186     </div>
187
188   </body>
189 </html>