mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 04:22:41 +00:00
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:
parent
8656ac50ed
commit
ea0d7acbee
6 changed files with 119 additions and 57 deletions
14
lib/expr.ml
14
lib/expr.ml
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue