From 6e791e31999db5aff1b8213fa2b22d2b54dc5fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwena=EBl=20Delaval?= Date: Fri, 2 Aug 2013 14:09:18 +0200 Subject: [PATCH] More permissive syntax (trailing commas/semicols) Allowing trailing commas and in parameters declarations --- compiler/heptagon/parsing/hept_parser.mly | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/heptagon/parsing/hept_parser.mly b/compiler/heptagon/parsing/hept_parser.mly index 8160fee..200affb 100644 --- a/compiler/heptagon/parsing/hept_parser.mly +++ b/compiler/heptagon/parsing/hept_parser.mly @@ -142,7 +142,7 @@ optsnlist(S,x) : /* Separated list with delimiter, even for empty list*/ adelim_slist(S, L, R, x) : | L R {[]} - | L l=snlist(S, x) R {l} + | L l=optsnlist(S, x) R {l} %inline tuple(x) : LPAREN h=x COMMA t=snlist(COMMA,x) RPAREN { h::t } %inline soption(P,x): @@ -230,7 +230,8 @@ params: ; nonmt_params: - | param { $1 } + | param { $1 } + | param SEMICOL { $1 } | param SEMICOL nonmt_params { $1 @ $3 } ; @@ -247,6 +248,7 @@ out_params: nonmt_out_params: | var_last { $1 } + | var_last SEMICOL { $1 } | var_last SEMICOL nonmt_out_params { $1 @ $3 } ; @@ -475,10 +477,15 @@ pat: ; nonmtexps: - | exp {[$1]} + | exp opt_comma {[$1]} | exp COMMA nonmtexps {$1 :: $3} ; +opt_comma: + | {} + | COMMA {} +; + exps: | /* empty */ {[]} | nonmtexps {$1}