diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index bb6f78f10..4b121e839 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -4,6 +4,6 @@
-
+
diff --git a/.idea/libraries/eclipse_lsp4j.xml b/.idea/libraries/eclipse_lsp4j.xml
new file mode 100644
index 000000000..fb8db4222
--- /dev/null
+++ b/.idea/libraries/eclipse_lsp4j.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 3887e5a4a..e986d3fcd 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,6 +2,8 @@
+
+
@@ -12,10 +14,10 @@
-
+
-
+
\ No newline at end of file
diff --git a/beanshell/beanshell.iml b/beanshell/beanshell.iml
new file mode 100644
index 000000000..cabe3f4c3
--- /dev/null
+++ b/beanshell/beanshell.iml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/beanshell/build.gradle.kts b/beanshell/build.gradle.kts
new file mode 100644
index 000000000..d9526d7cd
--- /dev/null
+++ b/beanshell/build.gradle.kts
@@ -0,0 +1,83 @@
+plugins {
+ kotlin("jvm")
+ id("application")
+}
+
+val serverMainClassName = "prog8lsp.MainKt"
+val applicationName = "prog8-beanshell"
+
+application {
+ mainClass.set(serverMainClassName)
+ description = "Code completions, diagnostics and more for Prog8"
+ // applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$version")
+ applicationDistribution.into("bin") {
+ filePermissions {
+ user {
+ read=true
+ execute=true
+ write=true
+ }
+ other.execute = true
+ group.execute = true
+ }
+ }
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ implementation(files("lib/bsh-3.0.0-SNAPSHOT.jar"))
+}
+
+configurations.forEach { config ->
+ config.resolutionStrategy {
+ preferProjectModules()
+ }
+}
+
+sourceSets.main {
+ java.srcDir("src")
+ resources.srcDir("resources")
+}
+
+sourceSets.test {
+ java.srcDir("src")
+ resources.srcDir("resources")
+}
+
+tasks.startScripts {
+ applicationName = "prog8-beanshell"
+}
+
+tasks.register("fixFilePermissions") {
+ // When running on macOS or Linux the start script
+ // needs executable permissions to run.
+
+ onlyIf { !System.getProperty("os.name").lowercase().contains("windows") }
+ commandLine("chmod", "+x", "${tasks.installDist.get().destinationDir}/bin/prog8-beanshell")
+}
+
+tasks.withType() {
+ testLogging {
+ events("failed")
+ exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
+ }
+}
+
+tasks.installDist {
+ finalizedBy("fixFilePermissions")
+}
+
+tasks.build {
+ finalizedBy("installDist")
+}
+
+val javaVersion: String by project
+
+kotlin {
+ jvmToolchain {
+ languageVersion = JavaLanguageVersion.of(javaVersion.toInt())
+ }
+}
\ No newline at end of file
diff --git a/beanshell/lib/bsh-3.0.0-SNAPSHOT.jar b/beanshell/lib/bsh-3.0.0-SNAPSHOT.jar
new file mode 100644
index 000000000..1cea7ea78
Binary files /dev/null and b/beanshell/lib/bsh-3.0.0-SNAPSHOT.jar differ
diff --git a/beanshell/src/prog8beanshell/CommandLineReader.kt b/beanshell/src/prog8beanshell/CommandLineReader.kt
new file mode 100644
index 000000000..a242c8de2
--- /dev/null
+++ b/beanshell/src/prog8beanshell/CommandLineReader.kt
@@ -0,0 +1,48 @@
+package prog8beanshell
+
+import java.io.FilterReader
+import java.io.Reader
+
+
+class CommandLineReader(val input: Reader): FilterReader(input) {
+ private val normal = 0
+ private val lastCharNL = 1
+ private val sentSemi = 2
+ private var state = lastCharNL
+
+ override fun read(): Int {
+ if (state == sentSemi) {
+ this.state = lastCharNL
+ return 10
+ } else {
+ var b = input.read()
+ while(b==13) b = input.read()
+
+ if (b == 10) {
+ if (this.state == lastCharNL) {
+ b = 59
+ this.state = sentSemi
+ } else {
+ this.state = lastCharNL
+ }
+ } else {
+ this.state = normal
+ }
+
+ return b
+ }
+
+ }
+
+ override fun read(buff: CharArray, off: Int, len: Int): Int {
+ val b = read()
+ if (b == -1) {
+ return -1
+ } else {
+ buff[off] = b.toChar()
+ return 1
+ }
+
+ }
+}
+
diff --git a/beanshell/src/prog8beanshell/Main.kt b/beanshell/src/prog8beanshell/Main.kt
new file mode 100644
index 000000000..9c2488169
--- /dev/null
+++ b/beanshell/src/prog8beanshell/Main.kt
@@ -0,0 +1,23 @@
+package prog8beanshell
+
+import bsh.FileReader
+import bsh.Interpreter
+
+
+class BeanshellInterpreter {
+
+ fun run(symbols: Map) {
+ val interpreter = Interpreter(CommandLineReader(FileReader(System.`in`)), System.out, System.err, true)
+ interpreter.setExitOnEOF(false)
+ symbols.forEach { (name, value) -> interpreter.set(name, value) }
+ interpreter.run()
+ }
+}
+
+fun main(args: Array) {
+ val i = BeanshellInterpreter()
+ i.run(mapOf(
+ "env" to System.getenv(),
+ "args" to args
+ ))
+}
diff --git a/compiler/build.gradle b/compiler/build.gradle
index 16eade8b0..2d8881ff7 100644
--- a/compiler/build.gradle
+++ b/compiler/build.gradle
@@ -32,6 +32,7 @@ dependencies {
implementation project(':codeGenIntermediate')
implementation project(':codeGenExperimental')
implementation project(':virtualmachine')
+ // implementation project(':beanshell')
implementation "org.antlr:antlr4-runtime:4.13.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
// implementation "org.jetbrains.kotlin:kotlin-reflect"
diff --git a/compiler/compiler.iml b/compiler/compiler.iml
index 8bbb96375..d43f3eaf9 100644
--- a/compiler/compiler.iml
+++ b/compiler/compiler.iml
@@ -25,5 +25,6 @@
+
\ No newline at end of file
diff --git a/docs/source/todo.rst b/docs/source/todo.rst
index 3da514fe3..25266e70c 100644
--- a/docs/source/todo.rst
+++ b/docs/source/todo.rst
@@ -1,8 +1,6 @@
TODO
====
-- check benchmark score vs previous version
-
- writing a 'txt' block in user program suddenly spews out all textio unused reference warnings because of the %option merge promotion going on. Merging should probably be handled differently
diff --git a/settings.gradle b/settings.gradle
index c68f1b9b6..3b825d1c3 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -8,5 +8,6 @@ include(
':codeGenIntermediate',
':codeGenCpu6502',
':codeGenExperimental',
- ':compiler'
+ ':compiler',
+ ':beanshell'
)