interpreter: minor fixes, changes to the main binary to actually interpret some source code
All checks were successful
ci/woodpecker/push/debian Pipeline was successful
ci/woodpecker/push/nix Pipeline was successful
ci/woodpecker/push/fedora Pipeline was successful
ci/woodpecker/push/publish Pipeline was successful
ci/woodpecker/cron/debian Pipeline was successful
ci/woodpecker/cron/nix Pipeline was successful
ci/woodpecker/cron/fedora Pipeline was successful
ci/woodpecker/cron/publish Pipeline was successful

This commit is contained in:
2026-03-22 17:23:49 +03:00
parent 040353683f
commit 4792a296d3
4 changed files with 16 additions and 22 deletions

View File

@@ -1,22 +1,16 @@
let def = Parser.parse_str "(define (f)
(let ((x 5))
(if t (set! x (+ x 1)))))
(define (f)
(define (g y) (* y 2))
(or (g 5) (g 6)))
(cond
((> 1 2) 0)
((> 3 2) 3)
(t -1))";;
let ( let* ) = Result.bind;;
let e =
(*let def = Parser.parse_str "(lambda () (+ x 1) (+ x 1))" in
*)
let* top = Compiler.Syntactic_ast.make (List.hd def) in
Ok (Printf.printf "%s\n" (Compiler.Syntactic_ast.print top))
let _ = match e with
| Error s -> Printf.printf "%s\n" s
(* Try to interpret some test source code. *)
let some_source = "(define (+ a b) b)
(+ 1 2)";;
(* I don't have any built-in functions at all rn, so we just use a dummy function *)
let bruh =
let* res = Interpreter.Main.interpret_src some_source in
match res with
| Int x -> Printf.printf "got %d as result\n" x; Ok ()
| _ -> Printf.printf "got something else\n" ; Ok ()
let _ =
match bruh with
| Error s -> Printf.printf "%s" s
| _ -> ()

View File

@@ -1,4 +1,4 @@
(executable
(name comp)
(public_name ollisp)
(libraries str unix compiler))
(libraries str unix compiler interpreter))