<div class="gmail_quote">2012/6/19 Leonard de HARO <span dir="ltr">&lt;<a href="mailto:leonard.de.haro@ens.fr" target="_blank">leonard.de.haro@ens.fr</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello,<br>
<br>
I&#39;m a french undergraduated CS. student currently doing an internship in<br>
Santigo&#39;s University under the supervision of Eric Tanter. I&#39;m working on<br>
the meta JIT compiler provided in the pypy project, trying to document<br>
it&#39;s performance on different kind of interpreters. I started two weeks<br>
ago.<br>
<br>
I have a problem with the translation toolchain. I&#39;ve been writing an<br>
interpreter for a small language inspired by Shriram Krishnamurthi&#39;s F1WAE<br>
from his book &quot;Programming Languages: Application and Interpretation&quot;.<br>
My problem is the following: I have an interpreter that seems to work<br>
perfecty (at least on my examples) when I use pypy interpreters, but<br>
whenever I translate it, execution fails. The fact is: I have identified<br>
the source of the problem but I don&#39;t understand it.<br>
If you look at the parser file, on line 184, there is a &quot;print&quot;<br>
instruction. With this instruction on comment, the translated version of<br>
RPinterpret executed on test10run10 gets a Stack Overflow. Use a<br>
translated version of the same file (RPinterpret.py) with the print<br>
instruction in parser.py, you get the normal behavior (which you have<br>
anyway using &quot;pypy RPinterpret.py test10runs10&quot;).</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Looks like a bug, but since I&#39;m a beginer (both on this work and on Python<br>
in general), maybe I have missed something.<br></blockquote><div><br></div><div>Hum, looks like a RPython oddness.</div><div>It seems that you have to catch IndexError for IndexError to be raised by the operation...</div>

<div><br></div><div>def CutWord(string, i): </div><div>    try:</div><div>        if string[i] in (&#39; &#39;, &#39;\n&#39;, &#39;\t&#39;): </div><div>            return i </div><div>    except IndexError:</div><div>        return i</div>
<div>    return CutWord(string, i+1)</div><div><br></div><div>But I think a loop would be much more efficient...</div><div><br></div><div>-- </div></div>Amaury Forgeot d&#39;Arc<br>