<pre><code>coffee> puts "#num bottles of beer" for num in [99..1]
</code></pre></td><tdclass="code"><divclass="highlight"><pre></pre></div></td></tr><trid="section-2"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-2">#</a></div><p>Require the <strong>coffee-script</strong> module to get access to the compiler.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">CoffeeScript</span><spanclass="o">=</span><spanclass="nx">require</span><spanclass="s1">'./coffee-script'</span>
<spanclass="nx">readline</span><spanclass="o">=</span><spanclass="nx">require</span><spanclass="s1">'readline'</span></pre></div></td></tr><trid="section-3"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-3">#</a></div><p>Start by opening up <strong>stdio</strong>.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">stdio</span><spanclass="o">=</span><spanclass="nx">process</span><spanclass="p">.</span><spanclass="nx">openStdin</span><spanclass="p">()</span></pre></div></td></tr><trid="section-4"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-4">#</a></div><p>Quick alias for quitting the REPL.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">helpers</span><spanclass="p">.</span><spanclass="nx">extend</span><spanclass="nx">global</span><spanclass="p">,</span><spanclass="nv">quit: </span><spanclass="o">-></span><spanclass="nx">process</span><spanclass="p">.</span><spanclass="nx">exit</span><spanclass="p">(</span><spanclass="mi">0</span><spanclass="p">)</span></pre></div></td></tr><trid="section-5"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-5">#</a></div><p>The main REPL function. <strong>run</strong> is called every time a line of code is entered.
of exiting.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">run</span><spanclass="o">=</span><spanclass="p">(</span><spanclass="nx">buffer</span><spanclass="p">)</span><spanclass="o">-></span>
<spanclass="nx">repl</span><spanclass="p">.</span><spanclass="nx">prompt</span><spanclass="p">()</span></pre></div></td></tr><trid="section-6"><tdclass="docs"><divclass="octowrap"><aclass="octothorpe"href="#section-6">#</a></div><p>Create the REPL by listening to <strong>stdin</strong>.</p></td><tdclass="code"><divclass="highlight"><pre><spanclass="nx">repl</span><spanclass="o">=</span><spanclass="nx">readline</span><spanclass="p">.</span><spanclass="nx">createInterface</span><spanclass="nx">stdio</span>