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

10
lib/stmt.ml Normal file
View file

@ -0,0 +1,10 @@
type stmt = Expr of Expr.expr_node | Print of Expr.expr_node
and stmt_node = { stmt : stmt; pos : Error.code_pos }
let make_expr_stmt (pos : Error.code_pos) (expr : Expr.expr_node) : stmt_node =
let stmt = Expr expr in
{ stmt; pos }
let make_print (pos : Error.code_pos) (expr : Expr.expr_node) : stmt_node =
let stmt = Print expr in
{ stmt; pos }