mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Add tuples to the surface language
No helpers to destruct them at the moment
This commit is contained in:
parent
50730ab8ff
commit
df3ab64fe9
@ -588,6 +588,7 @@ let rec translate_expr
|
||||
in
|
||||
Expr.ematch ~e:(rec_helper e1) ~name:enum_uid ~cases emark
|
||||
| ArrayLit es -> Expr.earray (List.map rec_helper es) emark
|
||||
| Tuple es -> Expr.etuple (List.map rec_helper es) emark
|
||||
| CollectionOp (((S.Filter { f } | S.Map { f }) as op), collection) ->
|
||||
let collection = rec_helper collection in
|
||||
let param_name, predicate = f in
|
||||
|
@ -315,6 +315,13 @@ let rec process_base_typ
|
||||
( TArray
|
||||
(process_base_typ ctxt (Surface.Ast.Data (Mark.remove t), Mark.get t)),
|
||||
typ_pos )
|
||||
| Surface.Ast.Data (Surface.Ast.TTuple tl) ->
|
||||
( TTuple
|
||||
(List.map
|
||||
(fun t ->
|
||||
process_base_typ ctxt (Surface.Ast.Data (Mark.remove t), Mark.get t))
|
||||
tl),
|
||||
typ_pos )
|
||||
| Surface.Ast.Data (Surface.Ast.Primitive prim) -> (
|
||||
match prim with
|
||||
| Surface.Ast.Integer -> TLit TInt, typ_pos
|
||||
|
@ -55,6 +55,7 @@ and primitive_typ =
|
||||
and base_typ_data =
|
||||
| Primitive of primitive_typ
|
||||
| Collection of base_typ_data Mark.pos
|
||||
| TTuple of base_typ_data Mark.pos list
|
||||
|
||||
and base_typ = Condition | Data of base_typ_data
|
||||
|
||||
@ -187,6 +188,7 @@ and naked_expression =
|
||||
| StructLit of
|
||||
(path * uident Mark.pos) Mark.pos * (lident Mark.pos * expression) list
|
||||
| ArrayLit of expression list
|
||||
| Tuple of expression list
|
||||
| Ident of path * lident Mark.pos
|
||||
| Dotted of expression * (path * lident Mark.pos) Mark.pos
|
||||
(** Dotted is for both struct field projection and sub-scope variables *)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -120,6 +120,11 @@ let primitive_typ :=
|
||||
let typ_data :=
|
||||
| t = primitive_typ ; <Primitive>
|
||||
| LIST ; t = addpos(typ_data) ; <Collection>
|
||||
| LPAREN ; tl = separated_nonempty_list(COMMA,addpos(typ_data)) ; RPAREN ; {
|
||||
match tl with
|
||||
| [t, _] -> t
|
||||
| ts -> TTuple ts
|
||||
}
|
||||
|
||||
let typ == t = typ_data ; <Data>
|
||||
|
||||
@ -167,7 +172,11 @@ let naked_expression ==
|
||||
| l = literal ; {
|
||||
Literal l
|
||||
}
|
||||
| LPAREN ; e = expression ; RPAREN ; <Paren>
|
||||
| LPAREN ; el = separated_nonempty_list(COMMA, expression) ; RPAREN ; {
|
||||
match el with
|
||||
| [e] -> Paren e
|
||||
| es -> Tuple es
|
||||
}
|
||||
| e = expression ;
|
||||
DOT ; i = addpos(qlident) ; <Dotted>
|
||||
| CARDINAL ; {
|
||||
|
Loading…
Reference in New Issue
Block a user