Pretty Scheme, ??? Python

Neil Cerutti horpner at yahoo.com
Tue Jul 3 13:24:24 EDT 2007


On 2007-07-03, Paul McGuire <ptmcg at austin.rr.com> wrote:
> 2. Change the parse actions to deref the 0'th element of t for
> binop and with_.
>
> num.setParseAction(lambda t: Num(int(t.number)))
> id_.setParseAction(lambda t: Id(t.name))
> binop.setParseAction(lambda t: BinOp(t[0].op, t[0].lhs, t[0].rhs))
> with_.setParseAction(lambda t: With(t[0].bound_id, t[0].named_expr,
> t[0].bound_body))

Thanks, that solves it.

Now to get on with this exercise and find out which version turns
out to be easier to modify and extend as the book progresses
through all the different programming language features it
covers. Scheme is bound to have an unfair advantage, though, as
the book was composed for Scheme.

I plan to see if I can create a class factory that behaves like
the define-type macro, though. That should prove rather useful.
The most tedious thing about the Python version is the cruft
required by the class hierarchy.

-- 
Neil Cerutti
I pulled into a lay-by with smoke coming from under the bonnet. I realized the
car was on fire so took my dog and smothered it with a blanket. --Insurance
Claim Blooper



More information about the Python-list mailing list