From f9ffc7b8e7e17b18f9f76c030fd5cd4d0c34494f Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Tue, 26 Mar 2019 17:25:42 +0100 Subject: [PATCH] List elements are now consistently separated by semicolons. --- AST.ml | 4 ++-- AST.mli | 4 ++-- Parser.mly | 15 +++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/AST.ml b/AST.ml index 82d4394c2..9c63b5226 100644 --- a/AST.ml +++ b/AST.ml @@ -639,7 +639,7 @@ and selection = | Component of (Lexer.lexeme * Z.t) reg and tuple_expr = - TupleInj of tuple_injection + TupleInj of tuple_injection and tuple_injection = (expr, comma) nsepseq par reg @@ -673,7 +673,7 @@ and pattern = | PTuple of (pattern, comma) nsepseq par reg and list_pattern = - Sugar of (pattern, comma) sepseq brackets reg + Sugar of (pattern, semi) sepseq brackets reg | Raw of (pattern * cons * pattern) par reg (* Projecting regions *) diff --git a/AST.mli b/AST.mli index 405f68f92..1b516383c 100644 --- a/AST.mli +++ b/AST.mli @@ -623,7 +623,7 @@ and selection = | Component of (Lexer.lexeme * Z.t) reg and tuple_expr = - TupleInj of tuple_injection + TupleInj of tuple_injection and tuple_injection = (expr, comma) nsepseq par reg @@ -657,7 +657,7 @@ and pattern = | PTuple of (pattern, comma) nsepseq par reg and list_pattern = - Sugar of (pattern, comma) sepseq brackets reg + Sugar of (pattern, semi) sepseq brackets reg | Raw of (pattern * cons * pattern) par reg (* Projecting regions *) diff --git a/Parser.mly b/Parser.mly index ddce8306e..1eb7963a0 100644 --- a/Parser.mly +++ b/Parser.mly @@ -528,6 +528,8 @@ map_patch: in {region; value} } +(* Note: [list_injection] and [set_injection] could be merged. *) + set_injection: Set series(expr,End) { let first, (others, terminator, closing) = $2 in @@ -930,8 +932,7 @@ core_expr: | C_True { ELogic (BoolExpr (True $1)) } | C_Unit { EUnit $1 } | tuple_expr { ETuple $1 } -| list_expr { EList (List $1) } -| nil { EList (Nil $1) } +| list_expr { EList $1 } | none_expr { EConstr (NoneExpr $1) } | fun_call { ECall $1 } | map_expr { EMap $1 } @@ -1015,6 +1016,12 @@ arguments: tuple_inj { $1 } list_expr: + list_injection { List $1 } +| nil { Nil $1 } + +(* Note: [list_injection] and [set_injection] could be merged. *) + +list_injection: List series(expr,End) { let first, (others, terminator, closing) = $2 in let region = cover $1 closing @@ -1095,8 +1102,8 @@ core_pattern: in PSome {region; value = $1,$2}} list_patt: - brackets(sepseq(core_pattern,COMMA)) { Sugar $1 } -| par(cons_pattern) { Raw $1 } + brackets(sepseq(core_pattern,SEMI)) { Sugar $1 } +| par(cons_pattern) { Raw $1 } cons_pattern: core_pattern CONS pattern { $1,$2,$3 }