esolang 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,391 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Esolang::Interpreters::Brainfuck
8
+
9
+ &mdash; Documentation by YARD 0.9.34
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Esolang::Interpreters::Brainfuck";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../Esolang.html" title="Esolang (module)">Esolang</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Interpreters.html" title="Esolang::Interpreters (module)">Interpreters</a></span></span>
41
+ &raquo;
42
+ <span class="title">Brainfuck</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Esolang::Interpreters::Brainfuck
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'><a href="BaseInterpreter.html" title="Esolang::Interpreters::BaseInterpreter (class)">BaseInterpreter</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next"><span class='object_link'><a href="BaseInterpreter.html" title="Esolang::Interpreters::BaseInterpreter (class)">BaseInterpreter</a></span></li>
78
+
79
+ <li class="next">Esolang::Interpreters::Brainfuck</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/interpreters/brainfuck_interpreter.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>The Brainfuck class represents an interpreter for the Brainfuck esoteric programming language.</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+
115
+ </div><div id="subclasses">
116
+ <h2>Direct Known Subclasses</h2>
117
+ <p class="children"><span class='object_link'><a href="Ook.html" title="Esolang::Interpreters::Ook (class)">Ook</a></span></p>
118
+ </div>
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+ <h2>
128
+ Instance Method Summary
129
+ <small><a href="#" class="summary_toggle">collapse</a></small>
130
+ </h2>
131
+
132
+ <ul class="summary">
133
+
134
+ <li class="public ">
135
+ <span class="summary_signature">
136
+
137
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(code, input = &#39;&#39;) &#x21d2; Brainfuck </a>
138
+
139
+
140
+
141
+ </span>
142
+
143
+
144
+ <span class="note title constructor">constructor</span>
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+ <span class="summary_desc"><div class='inline'>
154
+ <p>Initializes a new instance of the Brainfuck interpreter.</p>
155
+ </div></span>
156
+
157
+ </li>
158
+
159
+
160
+ <li class="public ">
161
+ <span class="summary_signature">
162
+
163
+ <a href="#run-instance_method" title="#run (instance method)">#<strong>run</strong> &#x21d2; String </a>
164
+
165
+
166
+
167
+ </span>
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+ <span class="summary_desc"><div class='inline'>
178
+ <p>Executes the interpretation of the Brainfuck code.</p>
179
+ </div></span>
180
+
181
+ </li>
182
+
183
+
184
+ </ul>
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+ <div id="constructor_details" class="method_details_list">
194
+ <h2>Constructor Details</h2>
195
+
196
+ <div class="method_details first">
197
+ <h3 class="signature first" id="initialize-instance_method">
198
+
199
+ #<strong>initialize</strong>(code, input = &#39;&#39;) &#x21d2; <tt><span class='object_link'><a href="" title="Esolang::Interpreters::Brainfuck (class)">Brainfuck</a></span></tt>
200
+
201
+
202
+
203
+
204
+
205
+ </h3><div class="docstring">
206
+ <div class="discussion">
207
+
208
+ <p>Initializes a new instance of the Brainfuck interpreter.</p>
209
+
210
+
211
+ </div>
212
+ </div>
213
+ <div class="tags">
214
+ <p class="tag_title">Parameters:</p>
215
+ <ul class="param">
216
+
217
+ <li>
218
+
219
+ <span class='name'>code</span>
220
+
221
+
222
+ <span class='type'>(<tt>String</tt>)</span>
223
+
224
+
225
+
226
+ &mdash;
227
+ <div class='inline'>
228
+ <p>The Brainfuck code to interpret.</p>
229
+ </div>
230
+
231
+ </li>
232
+
233
+ <li>
234
+
235
+ <span class='name'>input</span>
236
+
237
+
238
+ <span class='type'>(<tt>String</tt>)</span>
239
+
240
+
241
+ <em class="default">(defaults to: <tt>&#39;&#39;</tt>)</em>
242
+
243
+
244
+ &mdash;
245
+ <div class='inline'>
246
+ <p>The input for the Brainfuck program (optional).</p>
247
+ </div>
248
+
249
+ </li>
250
+
251
+ </ul>
252
+
253
+
254
+ </div><table class="source_code">
255
+ <tr>
256
+ <td>
257
+ <pre class="lines">
258
+
259
+
260
+ 13
261
+ 14
262
+ 15
263
+ 16
264
+ 17
265
+ 18
266
+ 19</pre>
267
+ </td>
268
+ <td>
269
+ <pre class="code"><span class="info file"># File 'lib/interpreters/brainfuck_interpreter.rb', line 13</span>
270
+
271
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_code'>code</span><span class='comma'>,</span> <span class='id identifier rubyid_input'>input</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
272
+ <span class='comment'># Added ? to valid chars for compatibility with Ook! But don&#39;t parse ? in Brainfuck
273
+ </span> <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_code'>code</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>[^\?,\.&lt;&gt;\+-\[\]]</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
274
+ <span class='ivar'>@input</span> <span class='op'>=</span> <span class='id identifier rubyid_chars_to_bytes'>chars_to_bytes</span><span class='lparen'>(</span><span class='id identifier rubyid_input'>input</span><span class='rparen'>)</span>
275
+ <span class='ivar'>@output</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
276
+ <span class='ivar'>@tape</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='int'>0</span><span class='rparen'>)</span>
277
+ <span class='kw'>end</span></pre>
278
+ </td>
279
+ </tr>
280
+ </table>
281
+ </div>
282
+
283
+ </div>
284
+
285
+
286
+ <div id="instance_method_details" class="method_details_list">
287
+ <h2>Instance Method Details</h2>
288
+
289
+
290
+ <div class="method_details first">
291
+ <h3 class="signature first" id="run-instance_method">
292
+
293
+ #<strong>run</strong> &#x21d2; <tt>String</tt>
294
+
295
+
296
+
297
+
298
+
299
+ </h3><div class="docstring">
300
+ <div class="discussion">
301
+
302
+ <p>Executes the interpretation of the Brainfuck code.</p>
303
+
304
+
305
+ </div>
306
+ </div>
307
+ <div class="tags">
308
+
309
+ <p class="tag_title">Returns:</p>
310
+ <ul class="return">
311
+
312
+ <li>
313
+
314
+
315
+ <span class='type'>(<tt>String</tt>)</span>
316
+
317
+
318
+
319
+ &mdash;
320
+ <div class='inline'>
321
+ <p>The result of the Brainfuck interpretation.</p>
322
+ </div>
323
+
324
+ </li>
325
+
326
+ </ul>
327
+
328
+ </div><table class="source_code">
329
+ <tr>
330
+ <td>
331
+ <pre class="lines">
332
+
333
+
334
+ 24
335
+ 25
336
+ 26
337
+ 27
338
+ 28
339
+ 29
340
+ 30
341
+ 31
342
+ 32
343
+ 33
344
+ 34
345
+ 35
346
+ 36
347
+ 37
348
+ 38
349
+ 39
350
+ 40
351
+ 41</pre>
352
+ </td>
353
+ <td>
354
+ <pre class="code"><span class="info file"># File 'lib/interpreters/brainfuck_interpreter.rb', line 24</span>
355
+
356
+ <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
357
+ <span class='kw'>while</span> <span class='id identifier rubyid_running?'>running?</span> <span class='kw'>do</span>
358
+ <span class='kw'>case</span> <span class='id identifier rubyid_command'>command</span>
359
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>,</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_input_to_tape'>input_to_tape</span>
360
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_tape_to_output_array'>tape_to_output_array</span>
361
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&gt;</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_move_right'>move_right</span>
362
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>&lt;</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_move_left'>move_left</span>
363
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>+</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_increment'>increment</span>
364
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>-</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_decrement'>decrement</span>
365
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>[</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_loop_begin'>loop_begin</span>
366
+ <span class='kw'>when</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>]</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>then</span> <span class='id identifier rubyid_loop_end'>loop_end</span>
367
+ <span class='kw'>end</span>
368
+
369
+ <span class='ivar'>@code_pointer</span> <span class='op'>+=</span> <span class='int'>1</span>
370
+ <span class='kw'>end</span>
371
+
372
+ <span class='id identifier rubyid_translate_output_bytes_to_chars'>translate_output_bytes_to_chars</span>
373
+ <span class='kw'>end</span></pre>
374
+ </td>
375
+ </tr>
376
+ </table>
377
+ </div>
378
+
379
+ </div>
380
+
381
+ </div>
382
+
383
+ <div id="footer">
384
+ Generated on Mon Jan 22 14:49:08 2024 by
385
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
386
+ 0.9.34 (ruby-3.1.2).
387
+ </div>
388
+
389
+ </div>
390
+ </body>
391
+ </html>