On Sep 19, 2009, at 10:45, Dag Sverre Seljebotn wrote:

> Magnus Lie Hetland wrote:
[snip]
>> IOW, I could just strip down the Cython code to get plain Python
>> equivalents that I could use the dev-tools on. Is that just a silly
>> idea? Would I be better off with pure mode? (Is there, perhaps,  
>> such a
>> beast/processor somewhere? I'm assuming I could reuse the Cython
>> parser if I needed to write something myself?)
>
> No, it's a good idea (though see below). The work is about 1/3 done I
> think... Compile/CodeWriter.py contains a tree transform which will
> serialize the tree back to Cython code which should be a good starting
> point (it only supports parts of the language currently though) --  
> it can
> simply have a flag or subclass to skip any type declarations, output  
> cdef
> classes as py classes etc.


I fiddled a bit with this, but found that the task was a bit too  
daunting compared to my current needs. I only need to strip away  
certain syntactic elements -- and reconstructing the entire program  
based on a parse tree was a bit heavy. A cool thing to have as part of  
the Cython toolchain, certainly, but a bit too much work for me right  
now.

What I ended up with for the moment is a very simple search/replace- 
based script that strips away the parts of the Cython syntax I'm  
currently using (preserving comments/whitespace, which the CodeWriter  
can't do either). Not sure how useful this is for others at the moment  
(as it only works with the most basic subset of functionality), but I  
guess I'll extend it as I use it in more of my code. (I also work with  
some others who will be using the same functionality.) If there's any  
interest, I'd be happy to make it available. (It's not exactly rocket  
science, though ;-)

Maybe I'll have the capacity to look into a more elegant solution some  
time in the future... :->

- M

-- 
Magnus Lie Hetland
http://hetland.org


_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to