Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Embedding the interactive interpreter
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
andris  
View profile  
 More options Nov 1, 3:39 pm
From: andris <and...@seznam.cz>
Date: Sun, 1 Nov 2009 12:39:04 -0800 (PST)
Local: Sun, Nov 1 2009 3:39 pm
Subject: Embedding the interactive interpreter
Hi,

I'm embedding the interpreter into a C# app using the
Boo.Lang.Interpreter.InteractiveInterpreter2 class. User input comes
from a winform Control (RichTextBox) and I call the
InteractiveInterpreter2.Eval(string code) method for any entered
lines.

How would I get all the output of the interpreter back to display to
user? Stdout can't probably be redirected, because that's used by the
host application for logging already, that must not mix up. I can
explore CompilerContext.Warnings and CompilerContext.Errors in the
result of Eval(), but don't see a way to display results of the
evaluation.

Thanks


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
andris  
View profile  
 More options Nov 1, 5:20 pm
From: andris <and...@seznam.cz>
Date: Sun, 1 Nov 2009 14:20:45 -0800 (PST)
Local: Sun, Nov 1 2009 5:20 pm
Subject: Re: Embedding the interactive interpreter
I forgot the Boo version: 0.9.2.3383

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo B. de Oliveira  
View profile  
 More options Nov 1, 7:28 pm
From: "Rodrigo B. de Oliveira" <rodrigobam...@gmail.com>
Date: Sun, 1 Nov 2009 16:28:02 -0800
Local: Sun, Nov 1 2009 7:28 pm
Subject: Re: Embedding the interactive interpreter
Hi there!

On Sun, Nov 1, 2009 at 12:39 PM, andris <and...@seznam.cz> wrote:
>...
> How would I get all the output of the interpreter back to display to
> user?

There's no output from the interpreter itself. Not for Eval anyway.

If the code says "print 'Hello!'" it would simply go to stdout.
There's this helper class ConsoleCapture that can be used for
capturing stdout somewhat conveniently:

    import Boo.Lang.Interpreter

    interpreter = InteractiveInterpreter2()

    using console = ConsoleCapture():
        interpreter.Eval("print 'Hello!'")

    assert 'Hello!' == console.ToString().Trim()

> Stdout can't probably be redirected, because that's used by the
> host application for logging already, that must not mix up.

So the above won't work for you I guess....

> I can
> explore CompilerContext.Warnings and CompilerContext.Errors in the
> result of Eval(), but don't see a way to display results of the
> evaluation.

You mean the value of the last evaluated expression? You can access
through the LastValue property but you must ask the interpreter to
remember it:

    import Boo.Lang.Interpreter

    interpreter = InteractiveInterpreter2(RememberLastValue: true)
    interpreter.Eval("2 * 21")
    assert 42 == interpreter.LastValue

Cheers,
Rodrigo


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
andris  
View profile  
 More options Nov 2, 6:34 am
From: andris <and...@seznam.cz>
Date: Mon, 2 Nov 2009 03:34:34 -0800 (PST)
Local: Mon, Nov 2 2009 6:34 am
Subject: Re: Embedding the interactive interpreter
Hi, thanks for the tips,

> If the code says "print 'Hello!'" it would simply go to stdout.
> There's this helper class ConsoleCapture that can be used for
> capturing stdout somewhat conveniently:

ConsoleCapture will help me, for application logging I have yet a
LogFileListener that can be used, receives log messages and saves to
file instead passing them to stdout, so stdout can be reserved for Boo
atm.

> You can access
> through the LastValue property but you must ask the interpreter to
> remember it:

I see, the LastValue might be useful. But it turns out that I need the
full console output more so that stuff like "for o in objects : print
o" can be used.

Best,
Andris


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google