Let's take a trivial piece of scheme code:
(lambda (design) (= #t #t))
Doesn't do much, does it? Don't need an editor to help you develop it? No. Not really. But it's a start. The following python code generated the above expression...and it should go without saying that this is really intended to be driven by a GUI and not manipulated by hand...but still...cool, eh?
>>> from tpcl.data import Import
>>> blocks = Import.LoadBlocks('tpcl/data/base_blocks.xml')
>>> exp = Representation.TpclExpression(blocks["INITIAL_BLOCK"]["Lambda Design"])
>>> bool = Representation.TpclExpression(blocks["BOOL"]["="])
>>> t1 = Representation.TpclExpression(blocks["VAL"]["#t"])
>>> t2 = Representation.TpclExpression(blocks["VAL"]["#t"])
>>> exp.InsertExpression(17, bool)
>>> Setting offset of expression to 17
>>> bool.InsertExpression(20, t1)
>>> Setting offset of expression to 20
>>> bool.InsertExpression(24, t2)
>>> Setting offset of expression to 23
>>> str(exp)
'(lambda (design) (= #t #t))'
-Fro
Subscribe to:
Post Comments (Atom)
1 comment:
Might I suggest wrapping your code in a "pre" or similar tag? It'll come through the feed much better.
Cool to see that you are working on the expression editor. Might I suggest reading up on S-Exp's which are the basis of Lisp, Scheme and thus TPCL. There is lots of good documentation on manipulating them from code. In fact lots of the power of Lisp comes from the ability to manipulate these expressions!
Post a Comment