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

View File

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

View File

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

View File

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