[pypy-dev] scheme parser.

Lenard Lindstrom len-l at telus.net
Fri May 11 00:07:42 CEST 2007

Armin Rigo wrote:
> Hi,
> On Wed, May 09, 2007 at 07:24:19PM -0300, Leonardo Santagada wrote:
>>> Now I am considering if the parser should generate some bytecode?
>>> Maybe pickling (not rpythonic) AST tree will be just fine (like in js
>>> interpreter)?
>> I am pickling the tree only if running on top of CPython, because  
>> RPython don't support that. And even then, it is really just a hack  
>> because parsing took a lot of time running on top of cpython. Iam  
>> going to give you the same advice I got from armin when I started...  
>> begin with AST and then when you have your parser ready we can see if  
>> using bytecode really get you faster.
> Yes, that's even more true for Scheme, where the AST is very simple.
> For now you should just interpret it, and we can see later if speed-ups
> can be achieved with bytecode.  Also, if you are directly using
> rlib.parsing, then you don't need any pickling: parse the source into an
> AST, and pass the AST objects directly to the interpreter.  (We can
> think later if it makes sense to add an equivalent of the .pyc files,
> but that's really questions for the very long term only.)

The lisp interpreter loop body is very simple:

(print (eval (read)))

First implement read and print. Implement eval when input can be 
reliably converted to s-expressions. There is no need for a distinct 
parser or special AST structures if that is the plan. That would come 
into play in writing a compiler.

Lenard Lindstrom
<len-l at telus.net>

More information about the Pypy-dev mailing list