mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 04:22:41 +00:00
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.
10 lines
358 B
OCaml
10 lines
358 B
OCaml
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 }
|