nRepl functionality has been added
This commit is contained in:
parent
426d19ccff
commit
52e2801fd2
11
README.md
11
README.md
|
@ -10,3 +10,14 @@ my [blog](https://lxsameer.com/).
|
||||||
|
|
||||||
## Repl
|
## Repl
|
||||||
in order to run the REPL, run `make repl`
|
in order to run the REPL, run `make repl`
|
||||||
|
|
||||||
|
## nRepl
|
||||||
|
Use `make nrepl` command to fire up a nRepl process and connect to it using `netcat` or something
|
||||||
|
similar. If you're using Emacs, there is a `serene-mode` available that distributes as part of
|
||||||
|
[FG42](https://gitlab.com/FG42/FG42/blob/master/lib/extensions/serene/serene-simple-mode.el).
|
||||||
|
|
||||||
|
Serene's nRepl is super simple. It waits for a newline char and then evaluates the
|
||||||
|
given input. It sends back the result of the evaluation in `<status-char><value>` format.
|
||||||
|
`status-char` is either `0` or `1`. **Zero** means the evaluation was successful and the `value`
|
||||||
|
is the result of evaluation while **one** means there was an error during the evaluation and
|
||||||
|
the `value` is the traceback for the exception.
|
||||||
|
|
|
@ -115,6 +115,13 @@ public class Main {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serene's nRepl is super simple. It waits for a newline char and then evaluates the
|
||||||
|
* given input. It sends back the result of the evaluation in `<status-char><value>` format.
|
||||||
|
* `status-char` is either `0` or `1`. **Zero** means the evaluation was successful and the `value`
|
||||||
|
* is the result of evaluation while **one** means there was an error during the evaluation and
|
||||||
|
* the `value` is the traceback for the exception.
|
||||||
|
*/
|
||||||
public static void nrepl() throws IOException {
|
public static void nrepl() throws IOException {
|
||||||
RootScope rootScope = new RootScope();
|
RootScope rootScope = new RootScope();
|
||||||
ServerSocket socket = new ServerSocket(Main.port);;
|
ServerSocket socket = new ServerSocket(Main.port);;
|
||||||
|
@ -124,6 +131,8 @@ public class Main {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
String.format("nRepl has been started on tcp://%s:%s", Main.host, Main.port));
|
String.format("nRepl has been started on tcp://%s:%s", Main.host, Main.port));
|
||||||
|
|
||||||
|
// NOTE: The nRepl server is too simple. It supports one connection at a time
|
||||||
|
// and will terminate when the client disconnects.
|
||||||
try {
|
try {
|
||||||
Socket clientSocket = socket.accept();
|
Socket clientSocket = socket.accept();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue