Skip to content

Commit 7926f27

Browse files
authored
Merge pull request #113 from engboris/repl
Add binary for interactive interpreter (REPL)
2 parents 0c1cd13 + 3fb7434 commit 7926f27

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

bin/dune

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(executables
2-
(public_names lsc sgen)
3-
(names lscrun sgen)
2+
(public_names lsc sgen isgen)
3+
(names lscrun sgen isgen)
44
(libraries lsc stellogen base))
55

66
(env

bin/isgen.ml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
open Base
2+
3+
let rec loop env =
4+
let lexbuf = Lexing.from_channel Stdlib.stdin in
5+
let d = Stellogen.Sgen_parser.declaration Stellogen.Sgen_lexer.read lexbuf in
6+
let wrapped_env =
7+
Stellogen.Sgen_eval.eval_decl ~typecheckonly:false ~notyping:false env d
8+
in
9+
match wrapped_env with
10+
| Ok env' -> loop env'
11+
| Error e ->
12+
let ( let* ) x f = Result.bind x ~f in
13+
let* pp = Stellogen.Sgen_eval.pp_err ~notyping:false e in
14+
Stdlib.output_string Stdlib.stderr pp;
15+
Stdlib.flush Stdlib.stderr;
16+
loop env
17+
18+
let () =
19+
let _ = loop Stellogen.Sgen_ast.initial_env in
20+
()

src/stellogen/sgen_parser.mly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ open Sgen_ast
1818
%token PROOF LEMMA THEOREM
1919

2020
%start <Sgen_ast.program> program
21+
%start <Sgen_ast.declaration> declaration
2122

2223
%%
2324

0 commit comments

Comments
 (0)