Why do you need a weird two-phase reading system to deal with the EOF issue?<div><br></div><div>Robby<br><br>On Monday, December 10, 2012, Jay McCarthy  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The datalog language tries to do this too.<div><br></div><div>There&#39;s a repl-submit? predicate you can use and I have weird two-phase reading system to deal with the EOF issue:</div><div><br></div><div><a href="https://github.com/plt/racket/blob/master/collects/datalog/lang/configure-runtime.rkt" target="_blank">https://github.com/plt/racket/blob/master/collects/datalog/lang/configure-runtime.rkt</a><br>

</div><div><br></div><div><a href="https://github.com/plt/racket/blob/master/collects/datalog/tool/submit.rkt" target="_blank">https://github.com/plt/racket/blob/master/collects/datalog/tool/submit.rkt</a><br></div><div>
<br></div><div>Jay</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 10, 2012 at 8:04 AM, Matthew Flatt <span dir="ltr">&lt;<a href="javascript:_e({}, &#39;cvml&#39;, &#39;mflatt@cs.utah.edu&#39;);" target="_blank">mflatt@cs.utah.edu</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When you run plain `racket&#39;, the REPL is `read-eval-print-loop&#39;, which<br>
uses `(current-prompt-read)&#39;, `(current-eval)&#39;, and `(current-print)&#39;.<br>
<br>
Any line-editing capability is whatever the terminal does, which<br>
normally means that input is sent to the reader when you hit Return.<br>
Even if you load `readline&#39; or `xrepl&#39;, a Return commits a line of<br>
characters to be sent off to the reader.<br>
<br>
The delivery of an expression to the evaluator, however, is determined<br>
by the reader. That is, if your reader sees a &quot;fun&quot; that should match<br>
an &quot;end&quot;, then it should keep reading input characters until it sees<br>
the &quot;end&quot;. When the reader returns a datum, then it&#39;s passed off to the<br>
evaluator.<br>
<br>
(If an interactive EOF is needed to terminate a form for your reader,<br>
that shouldn&#39;t necessarily make the REPL quit. The REPL should quit<br>
only when the reader returns an EOF. So, a reader might consume an<br>
interactive EOF as a terminator, and then it can continue reading the<br>
next time around.)<br>
<br>
If I remember correctly, DrRacket is a little different. A Return in<br>
DrRacket takes the text so far and implicitly adds an EOF to the end.<br>
If the reader applied to that text raises `exn:fail:read:eof&#39;, then<br>
DrRacket it as an indication that the expression isn&#39;t finished, and so<br>
it lets the user keep editing on the next line. Meanwhile, an<br>
`exn:fail:read&#39; exception other than the subtype `exn:fail:read:eof&#39;<br>
means that the read error should be reported to the user.<br>
<div><div><br>
<br>
At Sun, 9 Dec 2012 19:03:44 -0500, Daniel Patterson wrote:<br>
&gt; I&#39;m working (with sk and jpolitz) on a non-sexp language built on top<br>
&gt; of racket.<br>
&gt;<br>
&gt; We have basic support for it in the repl inside DrRacket, but none at<br>
&gt; all from the racket commandline repl (which also means no support for<br>
&gt; embedding inside other editors) - and the former seems to be using<br>
&gt; s-exps to figure out when to send the input to our eval (I think - I<br>
&gt; haven&#39;t found documentation describing how this works).<br>
&gt;<br>
&gt; So my question is:<br>
&gt;<br>
&gt; Is there a way to specify how input is split before sending to eval,<br>
&gt; both so that DrRacket could follow our conventions (which might, for<br>
&gt; example, match a &quot;fun&quot; with matching &quot;end&quot;), and so that the<br>
&gt; commandline repl knows how to split input at all (as right now it just<br>
&gt; keeps waiting for input until EOF - and EOF also causes the repl to<br>
&gt; quit!) Is there something that read/read-syntax should signal, or another<br>
&gt; handler to use?<br>
&gt;<br>
&gt; Thanks!<br>
&gt; Daniel<br>
&gt; ____________________<br>
&gt;   Racket Users list:<br>
&gt;   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
____________________<br>
  Racket Users list:<br>
  <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jay McCarthy &lt;<a href="javascript:_e({}, &#39;cvml&#39;, &#39;jay@cs.byu.edu&#39;);" target="_blank">jay@cs.byu.edu</a>&gt;<br>Assistant Professor / Brigham Young University<br>
<a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>&quot;The glory of God is Intelligence&quot; - D&amp;C 93<br>
</div>
</blockquote></div>