started implementing expressions

Parser.parse now return list of statements or list of errors.
parsing continues until EOF, even when errors are found; but after the
first error the result can only be Error.
Also implemented Print and Expr statements.
This commit is contained in:
Moritz Gmeiner 2024-08-25 02:12:51 +02:00
commit ea0d7acbee
6 changed files with 119 additions and 57 deletions

View file

@ -1,12 +1,12 @@
type literal = String of string | Number of float | Bool of bool | Nil
(* [@@deriving show { with_path = false }] *)
[@@deriving show { with_path = false }]
let show_literal literal =
match literal with
| String s -> s
| Number x -> string_of_float x
| Bool b -> string_of_bool b
| Nil -> "nil"
(* let show_literal literal =
match literal with
| String s -> s
| Number x -> string_of_float x
| Bool b -> string_of_bool b
| Nil -> "nil" *)
type binary_op =
| Plus