- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Scripster - interactive scala REPL using telnet, http or swing
Tue, 2010-03-02, 03:32
I created a simple interactive gate to acces the scala REPL in any scala
process. It only uses one port and supports telnet, http and swing:
http://blog.homecloud.ca/2010/03/scripster-interactive-scala-repl-using....
The telnet version supports content assist but I don't know how to get the
options...if you guys can help point me in the right direction, would be
much appreciated.
Enjoy!
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter .
Thu, 2010-03-04, 14:37
#2
Re: Scripster - interactive scala REPL using telnet, http or s
Thanks.
1. I don't quite use the REPL. I evaluate each as an independent expression,
but in the same context/parser instance - i'm assuming the result is
similar...if not, I could have 2 'modes'...
// begin session
val env = new scala.tools.nsc.Settings
val p = new scala.tools.nsc.Interpreter (env)
// running the script - every time
val r = p.evalExpr[Any] (script)
2. yes. if you type in a and TAB you'll see the test options popup,
vi-filename-completion-style and expanded... for b there's only one so it's
expanded automatically
3. was having fun implementing a state machine and playing with DSLs. the
details are at:
http://blog.razie.com/2010/02/implementing-state-machine-in-scala-dsl.html
The telnet code is at:
http://github.com/razie/razweb/blob/master/src/com/razie/pub/http/Telnet...
Cool, thanks - I will send those options to switch the client to echo mode.
I see your telnet implementation is more complete, but I like the state
machine style now...maybe we can extract and keep just one from both?
Johannes Rudolph-2 wrote:
>
> Hi Razvan,
>
> thx for sharing that. I've got some questions:
>
> On Tue, Mar 2, 2010 at 3:32 AM, Razvan Cojocaru wrote:
>> I created a simple interactive gate to acces the scala REPL in any scala
>> process. It only uses one port and supports telnet, http and swing:
>> http://blog.homecloud.ca/2010/03/scripster-interactive-scala-repl-using....
>
> Is 'the scala REPL' really the interpreter from the distribution or
> did you create a REPL yourself? How does it differ from the Scala
> REPL?
>
>> The telnet version supports content assist but I don't know how to get
>> the
>> options...if you guys can help point me in the right direction, would be
>> much appreciated.
> I didn't try scripster yet and it is not clear what you mean here.
> What kind of content assist is supported in the telnet version right
> now? Is the basic infrastructure available but the part is missing
> which calculates possible completions at a particular position?
>
> BTW, I couldn't find the code in your repository which actually
> implements the telnet protocol. You can look at
> http://github.com/jrudolph/scala-stuff/blob/master/telnet/src/main/scala...
>
> how to set the options, so you don't have to change the mode in the
> telnet client manually:
>
> // request WindowSize handling
> is.write(IAC, DO, NAWS)
> // don't wait for GO_AHEAD before doing anything
> is.write(IAC, WILL, SUPPRESS_GO_AHEAD)
> // jline will echo all visible characters
> is.write(IAC, WILL, ECHO)
>
>
Thu, 2010-03-04, 21:37
#3
Re: Scripster - interactive scala REPL using telnet, http or s
I'm kind of stuck with the options...please help!!!
I got this far by inspecting code - but i keep getting an empty list of
options...
package razie.scripster.test
import scala.tools.{nsc => nsc}
object CompletionTest {
def main(args : Array[String]) : Unit = {
val env = new nsc.Settings
val p = new nsc.Interpreter (env)
val l = new java.util.ArrayList[String]()
val c = new nsc.interpreter.Completion(p)
val scr = "System."
c.topLevelFor (nsc.interpreter.Parsed(scr))
println ("options for: \'"+scr+"\' are: " +l)
}
}
-----
Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
http://twitter.com/razie Twitter , http://github.com/razie GitHub ..
Thu, 2010-03-04, 21:47
#4
Re: Scripster - interactive scala REPL using telnet, http or s
You probably have to initialize the Interpreter with a decent classpath.
On Thu, Mar 4, 2010 at 9:27 PM, Razvan Cojocaru wrote:
>
> I'm kind of stuck with the options...please help!!!
>
> I got this far by inspecting code - but i keep getting an empty list of
> options...
>
>
> package razie.scripster.test
> import scala.tools.{nsc => nsc}
>
> object CompletionTest {
> def main(args : Array[String]) : Unit = {
>
> val env = new nsc.Settings
> val p = new nsc.Interpreter (env)
> val l = new java.util.ArrayList[String]()
> val c = new nsc.interpreter.Completion(p)
>
> val scr = "System."
>
> c.topLevelFor (nsc.interpreter.Parsed(scr))
>
> println ("options for: \'"+scr+"\' are: " +l)
> }
> }
>
>
>
> -----
> Razvan Cojocaru,
> Work: http://www.sigma-systems.com
> Playground: http://wiki.homecloud.ca
> Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
> http://twitter.com/razie Twitter , http://github.com/razie GitHub ..
>
> --
> View this message in context: http://old.nabble.com/Scripster---interactive-scala-REPL-using-telnet%2C...
> Sent from the Scala - Tools mailing list archive at Nabble.com.
>
>
Thu, 2010-03-04, 21:57
#5
Re: Scripster - interactive scala REPL using telnet, http or s
java.util.System should be in the default classpath...
Either way, it should use the current classloader...it's meant to interact
with the current process, but i can't figure out how to convince it to...
Johannes Rudolph-2 wrote:
>
> You probably have to initialize the Interpreter with a decent classpath.
>
> On Thu, Mar 4, 2010 at 9:27 PM, Razvan Cojocaru wrote:
>>
>> I'm kind of stuck with the options...please help!!!
>>
>> I got this far by inspecting code - but i keep getting an empty list of
>> options...
>>
>>
>> package razie.scripster.test
>> import scala.tools.{nsc => nsc}
>>
>> object CompletionTest {
>> def main(args : Array[String]) : Unit = {
>>
>> val env = new nsc.Settings
>> val p = new nsc.Interpreter (env)
>> val l = new java.util.ArrayList[String]()
>> val c = new nsc.interpreter.Completion(p)
>>
>> val scr = "System."
>>
>> c.topLevelFor (nsc.interpreter.Parsed(scr))
>>
>> println ("options for: \'"+scr+"\' are: " +l)
>> }
>> }
>>
>>
>>
>> -----
>> Razvan Cojocaru,
>> Work: http://www.sigma-systems.com
>> Playground: http://wiki.homecloud.ca
>> Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
>> http://twitter.com/razie Twitter , http://github.com/razie GitHub ..
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Scripster---interactive-scala-REPL-using-telnet%2C...
>> Sent from the Scala - Tools mailing list archive at Nabble.com.
>>
>>
>
>
>
Thu, 2010-03-04, 22:07
#6
Re: Scripster - interactive scala REPL using telnet, http or s
On Thu, Mar 4, 2010 at 9:52 PM, Razvan Cojocaru wrote:
>
> java.util.System should be in the default classpath...
>
> Either way, it should use the current classloader...it's meant to interact
> with the current process, but i can't figure out how to convince it to...
Sure, but you have to distinguish between the runtime classpath and
the classpath for the Scala compiler. The classpath for the compiler
has to be specified separately. (see Interpreter.classpath)
Thu, 2010-03-04, 22:17
#7
Re: Scripster - interactive scala REPL using telnet, http or s
some just-in-time thinking...as I typed i realized I should try the entire
package. sure enough, thise sequence works:
val c = new nsc.interpreter.Completion(p)
val scr = "java.lang.Syste"
c.jline.complete (scr, scr.length-1, l)
c.jline.complete (scr, scr.length-1, l)
println ("options for: \'"+scr+"\' are: " +l)
----------
however, this again prints an empty thing:
val c = new nsc.interpreter.Completion(p)
val scr = "java.lang.Syste"
c.jline.complete (scr, scr.length-1, l)
c.jline.complete (scr, scr.length-1, l)
println ("options for: \'"+scr+"\' are: " +l)
---------
puzzly puzzle - unless the first one initializes something the second one
likes...
Razvan Cojocaru wrote:
>
> java.util.System should be in the default classpath...
>
> Either way, it should use the current classloader...it's meant to interact
> with the current process, but i can't figure out how to convince it to...
>
>
> Johannes Rudolph-2 wrote:
>>
>> You probably have to initialize the Interpreter with a decent classpath.
>>
>> On Thu, Mar 4, 2010 at 9:27 PM, Razvan Cojocaru wrote:
>>>
>>> I'm kind of stuck with the options...please help!!!
>>>
>>> I got this far by inspecting code - but i keep getting an empty list of
>>> options...
>>>
>>>
>>> package razie.scripster.test
>>> import scala.tools.{nsc => nsc}
>>>
>>> object CompletionTest {
>>> def main(args : Array[String]) : Unit = {
>>>
>>> val env = new nsc.Settings
>>> val p = new nsc.Interpreter (env)
>>> val l = new java.util.ArrayList[String]()
>>> val c = new nsc.interpreter.Completion(p)
>>>
>>> val scr = "System."
>>>
>>> c.topLevelFor (nsc.interpreter.Parsed(scr))
>>>
>>> println ("options for: \'"+scr+"\' are: " +l)
>>> }
>>> }
>>>
>>>
>>>
>>> -----
>>> Razvan Cojocaru,
>>> Work: http://www.sigma-systems.com
>>> Playground: http://wiki.homecloud.ca
>>> Follow me: http://feeds.razie.com/RazvanTech RSS Feed ,
>>> http://twitter.com/razie Twitter , http://github.com/razie GitHub ..
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Scripster---interactive-scala-REPL-using-telnet%2C...
>>> Sent from the Scala - Tools mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
Hi Razvan,
thx for sharing that. I've got some questions:
On Tue, Mar 2, 2010 at 3:32 AM, Razvan Cojocaru wrote:
> I created a simple interactive gate to acces the scala REPL in any scala
> process. It only uses one port and supports telnet, http and swing:
> http://blog.homecloud.ca/2010/03/scripster-interactive-scala-repl-using....
Is 'the scala REPL' really the interpreter from the distribution or
did you create a REPL yourself? How does it differ from the Scala
REPL?
> The telnet version supports content assist but I don't know how to get the
> options...if you guys can help point me in the right direction, would be
> much appreciated.
I didn't try scripster yet and it is not clear what you mean here.
What kind of content assist is supported in the telnet version right
now? Is the basic infrastructure available but the part is missing
which calculates possible completions at a particular position?
BTW, I couldn't find the code in your repository which actually
implements the telnet protocol. You can look at
http://github.com/jrudolph/scala-stuff/blob/master/telnet/src/main/scala...
how to set the options, so you don't have to change the mode in the
telnet client manually:
// request WindowSize handling
is.write(IAC, DO, NAWS)
// don't wait for GO_AHEAD before doing anything
is.write(IAC, WILL, SUPPRESS_GO_AHEAD)
// jline will echo all visible characters
is.write(IAC, WILL, ECHO)