Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-03 Thread Tuomas Utrecht
Le 2 mars 2012 11:26, Jeff Hardy a écrit : > On Fri, Mar 2, 2012 at 5:31 AM, Tuomas Utrecht > wrote: > > I have body of possible Excel formulas which are identical to Python > syntax, > > except for the use of ^. > > If that's the case, why not rewrite them as strings instead (i.e. > s/^/**/g),

Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-02 Thread Jeff Hardy
On Fri, Mar 2, 2012 at 5:31 AM, Tuomas Utrecht wrote: > I have body of possible Excel formulas which are identical to Python syntax, > except for the use of ^. If that's the case, why not rewrite them as strings instead (i.e. s/^/**/g), and then pass them to IronPython? - Jeff __

Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-02 Thread Tuomas Utrecht
No, my case is taking Excel formula strings into a C# application, redefining ^ to be ** and evaluating expressions in the context of a larger Python module which may override built-in and third-party Excel functions. Thank you for the information, though. Le 2 mars 2012 00:00, Vernon Cole a écr

Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-02 Thread Tuomas Utrecht
Le 1 mars 2012 21:58, Curt Hagenlocher a écrit : > I would argue that this is a bad idea. How Python-compatible do you want > this simple Excel-like language to be? > I have body of possible Excel formulas which are identical to Python syntax, except for the use of ^. > If it's really just a s

Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-01 Thread Vernon Cole
Err, ummm, ... Are you perhaps trying to reinvent Resolver 1 -- a spreadsheet written in Python? Maybe I misunderstand what you are trying to do, but you may want to look at it, unless you cannot use a commercial product. On Mar 1, 2012 7:58 PM, "Curt Hagenlocher" wrote: > I would argue that this

Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-01 Thread Curt Hagenlocher
I would argue that this is a bad idea. How Python-compatible do you want this simple Excel-like language to be? If it's really just a small subset of the full Python language, you may be better off writing a simple parser that emits Python text as its back end and prevents the users from doing anyt

Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-01 Thread Dino Viehland
[email protected] [mailto:[email protected]] On Behalf Of Tuomas Utrecht Sent: Thursday, March 01, 2012 4:01 PM To: [email protected] Subject: Re: [Ironpython-users] Modifying ASTs when embedding IronPython Ok, I'

Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-01 Thread Tuomas Utrecht
Ok, I'm going to read up on this, but to confirm, I'd need something like the following (from reading http://stackoverflow.com/questions/7944521/interrupt-interpreted-user-code-in-silverlight )? public class ExpressionRewriter : ExpressionVisitor { protected override Expression VisitBinary(Bin

Re: [Ironpython-users] Modifying ASTs when embedding IronPython

2012-03-01 Thread Dino Viehland
The ASTs are generally immutable so to re-write you'll create a copy of the AST and any parent nodes. The ExpressionVisitor class makes this easy in that you can override VisitExtension method and re-write any Python nodes you care about there. You return a modified node somewhere within the t