<div class="gmail_quote">2012/6/19 Leonard de HARO <span dir="ltr"><<a href="mailto:leonard.de.haro@ens.fr" target="_blank">leonard.de.haro@ens.fr</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I'm a french undergraduated CS. student currently doing an internship in<br>
Santigo's University under the supervision of Eric Tanter. I'm working on<br>
the meta JIT compiler provided in the pypy project, trying to document<br>
it's performance on different kind of interpreters. I started two weeks<br>
ago.<br>
<br>
I have a problem with the translation toolchain. I've been writing an<br>
interpreter for a small language inspired by Shriram Krishnamurthi's F1WAE<br>
from his book "Programming Languages: Application and Interpretation".<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't understand it.<br>
If you look at the parser file, on line 184, there is a "print"<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 "pypy RPinterpret.py test10runs10").</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'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 (' ', '\n', '\t'): </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'Arc<br>