mirror of https://github.com/japl-lang/japl.git
use jale instead of stdin.readLine
This commit is contained in:
parent
407939bd63
commit
8090fd23bb
|
@ -95,6 +95,14 @@ git clone https://github.com/japl-lang/japl
|
||||||
|
|
||||||
### Running the build script
|
### Running the build script
|
||||||
|
|
||||||
|
NOTE: as of now, you will need version 0.1.0 of the nimble package `jale` installed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/japl-lang/jale --branch 0.1.0
|
||||||
|
cd jale
|
||||||
|
nimble install
|
||||||
|
```
|
||||||
|
|
||||||
As a next step, you need to run JABT (YES, Just Another Build Tool). This will generate the required configuration files, compile the JAPL runtime and run tests (unless `--skip-tests` is used). There are some settings that can be tweaked with command-line options (or environment variables), for more information, run `python3 build.py --help`.
|
As a next step, you need to run JABT (YES, Just Another Build Tool). This will generate the required configuration files, compile the JAPL runtime and run tests (unless `--skip-tests` is used). There are some settings that can be tweaked with command-line options (or environment variables), for more information, run `python3 build.py --help`.
|
||||||
|
|
||||||
To compile the JAPL runtime, you'll first need to move into the project's directory you cloned before, so run `cd japl`, then `python3 build.py ./src` and wait for it to complete. You should now find an executable named `japl` (or `japl.exe` on windows) inside the `src` folder.
|
To compile the JAPL runtime, you'll first need to move into the project's directory you cloned before, so run `cd japl`, then `python3 build.py ./src` and wait for it to complete. You should now find an executable named `japl` (or `japl.exe` on windows) inside the `src` folder.
|
||||||
|
|
31
src/japl.nim
31
src/japl.nim
|
@ -25,6 +25,18 @@ import types/japlNil
|
||||||
import types/typeutils
|
import types/typeutils
|
||||||
import types/methods
|
import types/methods
|
||||||
|
|
||||||
|
import jale/editor
|
||||||
|
import jale/templates
|
||||||
|
import jale/plugin/defaults
|
||||||
|
import jale/plugin/history
|
||||||
|
import jale/plugin/editor_history
|
||||||
|
|
||||||
|
proc getLineEditor: LineEditor =
|
||||||
|
result = newLineEditor()
|
||||||
|
result.prompt = "=> "
|
||||||
|
result.populateDefaults() # setup default keybindings
|
||||||
|
let hist = result.plugHistory() # create history object
|
||||||
|
result.bindHistory(hist) # set default history keybindings
|
||||||
|
|
||||||
proc repl(bytecodeVM: VM) =
|
proc repl(bytecodeVM: VM) =
|
||||||
var bytecodeVM = bytecodeVM
|
var bytecodeVM = bytecodeVM
|
||||||
|
@ -34,18 +46,12 @@ proc repl(bytecodeVM: VM) =
|
||||||
let nimDetails = &"[Nim {NimVersion} on {hostOs} ({hostCPU})]"
|
let nimDetails = &"[Nim {NimVersion} on {hostOs} ({hostCPU})]"
|
||||||
echo nimDetails
|
echo nimDetails
|
||||||
var source = ""
|
var source = ""
|
||||||
while true:
|
let lineEditor = getLineEditor()
|
||||||
try:
|
var keep = true
|
||||||
stdout.write("=> ")
|
lineEditor.bindEvent(jeQuit):
|
||||||
source = stdin.readLine()
|
keep = false
|
||||||
except IOError:
|
while keep:
|
||||||
echo ""
|
source = lineEditor.read()
|
||||||
bytecodeVM.freeVM()
|
|
||||||
break
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
echo ""
|
|
||||||
bytecodeVM.freeVM()
|
|
||||||
break
|
|
||||||
if source == "//clear" or source == "// clear":
|
if source == "//clear" or source == "// clear":
|
||||||
echo "\x1Bc" & JAPL_VERSION_STRING
|
echo "\x1Bc" & JAPL_VERSION_STRING
|
||||||
echo nimDetails
|
echo nimDetails
|
||||||
|
@ -60,6 +66,7 @@ proc repl(bytecodeVM: VM) =
|
||||||
if not bytecodeVM.lastPop.isNil():
|
if not bytecodeVM.lastPop.isNil():
|
||||||
echo stringify(bytecodeVM.lastPop)
|
echo stringify(bytecodeVM.lastPop)
|
||||||
bytecodeVM.lastPop = cast[ptr Nil](bytecodeVM.cached[2])
|
bytecodeVM.lastPop = cast[ptr Nil](bytecodeVM.cached[2])
|
||||||
|
bytecodeVM.freeVM()
|
||||||
|
|
||||||
|
|
||||||
proc main(file: var string = "", fromString: bool = false, interactive: bool = false) =
|
proc main(file: var string = "", fromString: bool = false, interactive: bool = false) =
|
||||||
|
|
Loading…
Reference in New Issue