[parser] adding support for expressions

This commit is contained in:
dsac
2022-12-07 21:56:38 +01:00
parent e9e5cdcf4d
commit 839f7b77af
7 changed files with 221 additions and 16 deletions

View File

@@ -2,12 +2,40 @@ type ident = string
type location = Lexing.position * Lexing.position
type const =
| CBool of bool
| CInt of int
type monop =
| MOp_not
| MOp_minus
type binop =
| BOp_add | BOp_sub | BOp_mul | BOp_div | BOp_mod
| BOp_and | BOp_or | BOp_eq | BOp_neq
| BOp_le | BOp_lt | BOp_ge | BOp_gt
type triop =
| TOp_if
type base_ty =
| Tbool
| Tint
type p_pattern = string
and p_expression = string
type p_pattern =
| PP_var of ident
| PP_tuple of ident list
type p_expression =
| PE_Const of const
| PE_Var of ident
| PE_MonOp of monop * p_expression
| PE_BinOp of binop * p_expression * p_expression
| PE_TriOp of triop * p_expression * p_expression * p_expression
| PE_app of ident * p_expression list
| PE_tuple of p_expression list
| PE_pre of p_expression
| PE_arrow of p_expression * p_expression
type p_equation =
{ peq_patt: p_pattern;