General style changes, nothing major

This commit is contained in:
Emin Arslan
2025-10-14 19:01:29 +03:00
committed by Emin Arslan
parent a905ab2b42
commit 965804c18d
4 changed files with 17 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ open Printf;;
open Lisp;; open Lisp;;
open Eval;; open Eval;;
open Read;; open Read;;
let rec repl env c = let rec repl env c =
let () = printf ">>> "; Out_channel.flush Out_channel.stdout; in let () = printf ">>> "; Out_channel.flush Out_channel.stdout; in
match In_channel.input_line c with match In_channel.input_line c with
@@ -14,4 +15,5 @@ let rec repl env c =
Out_channel.flush Out_channel.stdout; Out_channel.flush Out_channel.stdout;
repl env c;; repl env c;;
let _ = repl (make_env ()) (In_channel.stdin)
let _ = repl (make_env ()) (In_channel.stdin)

View File

@@ -1,7 +1,5 @@
(library (library
(name lisp) (name lisp))
;(modules ast read lexer parser)
)
(include_subdirs unqualified) (include_subdirs unqualified)

View File

@@ -33,4 +33,3 @@ rule read =
| '\'' { QUOTE } | '\'' { QUOTE }
| _ { raise (SyntaxError ("Unexpected char: " ^ Lexing.lexeme lexbuf))} | _ { raise (SyntaxError ("Unexpected char: " ^ Lexing.lexeme lexbuf))}
| eof { EOF } | eof { EOF }

View File

@@ -15,20 +15,20 @@
%% %%
prog: prog:
| EOF { None } | EOF { None }
| e = expr { Some e } | e = expr { Some e }
; ;
expr: expr:
| i = INT { LInt i } | i = INT { LInt i }
| d = DOUBLE {LDouble d} | d = DOUBLE {LDouble d}
| s = SYM { LSymbol s } | s = SYM { LSymbol s }
| s = STR { LString (String.uppercase_ascii s) } | s = STR { LString (String.uppercase_ascii s) }
| LPAREN; l = lisp_list_rest { l } | LPAREN; l = lisp_list_rest { l }
| QUOTE; e = expr { LQuoted e} | QUOTE; e = expr { LQuoted e}
; ;
lisp_list_rest: lisp_list_rest:
| RPAREN { LNil } | RPAREN { LNil }
| e = expr; lr = lisp_list_rest { LCons (e, lr) } | e = expr; lr = lisp_list_rest { LCons (e, lr) }
; ;