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
10
lib/stmt.ml
Normal file
10
lib/stmt.ml
Normal 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 }
|
||||
Loading…
Add table
Add a link
Reference in a new issue