dlang-community / drepl

A REPL for D
Boost Software License 1.0
78 stars 20 forks source link

Allow void expressions, capture stdout, use dedicated parser for multiple statements per line #14

Closed callumenator closed 10 years ago

callumenator commented 10 years ago

Just some possible fixes for issues I found while playing with drepl (some of these are in the issue tracker, #2, #11).

Adding a dedicated parser inherited from stdx.parser allows to have multiple statements per line, but does now force the use of a semicolon to end expressions.

It also allows detecting the auto variable declarations to do the re-write into typeof(init); shared static this() { etc. } I haven't implemented the re-write because I can't test it. For some reason, when running the console.d example, declaring variables (int a; ) and then using them (a += 5; ) fails with dlopen complaining it can't allocate memory in static TLS. Function decls and such work OK.

take or leave :)

MartinNowak commented 10 years ago

fails with dlopen complaining it can't allocate memory in static TLS

Sound like this https://d.puremagic.com/issues/show_bug.cgi?id=12092, are you using a 32-bit system?

callumenator commented 10 years ago

Sound like this https://d.puremagic.com/issues/show_bug.cgi?id=12092, are you using a 32-bit system?

Yep 32 bit

MartinNowak commented 10 years ago

This is quite nice, but it also breaks a few things. I'll look into this more closely tomorrow.

MartinNowak commented 10 years ago

Sorry, the closing happened automatically because I mentioned, "partly fixes #14" in the commit message.

MartinNowak commented 10 years ago

I have had a hard time rebuilding the source using the AST Visitor.

I also had a hard time rebuilding the source from the tokens. We should tell @Hackerpilot about this, maybe there are some plans to improve the API.

Hackerpilot commented 10 years ago

I'm not exactly sure what's going on here. What features do you need?

MartinNowak commented 10 years ago

I'm not exactly sure what's going on here. What features do you need?

Maybe that was a bit rude. I was missing a function to convert tokens back into strings (eventually I copied it from the highlighter), @callumenator had troubles to convert AST into code using the visitor interface.

callumenator commented 10 years ago

Right to close this now?

Hackerpilot commented 10 years ago

The AST->Source conversion process is not finished. The progress that I've made so far is in the formatter module. It mostly just supports types.

MartinNowak commented 10 years ago

Maybe this can be done without requiring a semicolon? (on windows shift+enter goes to a new line on the terminal without actually sending a newline)

I opened #19 for that.

MartinNowak commented 10 years ago

The AST->Source conversion process is not finished. The progress that I've made so far is in the formatter module. It mostly just supports types.

Thanks, good to know.