From 68b6e6d3b08fdc7eb0f4a5a4bb003f6cb741d32c Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Wulfman Date: Fri, 21 Feb 2020 11:41:36 +0100 Subject: [PATCH] remove option(recursive) in Parser.mly; parse error still --- src/passes/1-parser/pascaligo/Parser.mly | 57 +++++++++++++++++++++--- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/src/passes/1-parser/pascaligo/Parser.mly b/src/passes/1-parser/pascaligo/Parser.mly index 10600d8c7..9dbaeafe8 100644 --- a/src/passes/1-parser/pascaligo/Parser.mly +++ b/src/passes/1-parser/pascaligo/Parser.mly @@ -237,10 +237,21 @@ field_decl: fun_expr: - ioption ("recursive") "function" parameters ":" type_expr "is" expr { + | "function" parameters ":" type_expr "is" expr { + let stop = expr_to_region $6 in + let region = cover $1 stop + and value = {kwd_recursive= None; + kwd_function = $1; + param = $2; + colon = $3; + ret_type = $4; + kwd_is = $5; + return = $6} + in {region; value} } + | "recursive" "function" parameters ":" type_expr "is" expr { let stop = expr_to_region $7 in let region = cover $2 stop - and value = {kwd_recursive= $1; + and value = {kwd_recursive= Some($1); kwd_function = $2; param = $3; colon = $4; @@ -252,12 +263,46 @@ fun_expr: (* Function declarations *) open_fun_decl: - ioption("recursive") "function" fun_name parameters ":" type_expr "is" + "function" fun_name parameters ":" type_expr "is" + block "with" expr { + Scoping.check_reserved_name $2; + let stop = expr_to_region $9 in + let region = cover $1 stop + and value = {kwd_recursive= None; + kwd_function = $1; + fun_name = $2; + param = $3; + colon = $4; + ret_type = $5; + kwd_is = $6; + block_with = Some ($7, $8); + return = $9; + terminator = None; + attributes = None} + in {region; value} + } +| "function" fun_name parameters ":" type_expr "is" expr { + Scoping.check_reserved_name $2; + let stop = expr_to_region $7 in + let region = cover $1 stop + and value = {kwd_recursive= None; + kwd_function = $1; + fun_name = $2; + param = $3; + colon = $4; + ret_type = $5; + kwd_is = $6; + block_with = None; + return = $7; + terminator = None; + attributes = None} + in {region; value} } +| "recursive" "function" fun_name parameters ":" type_expr "is" block "with" expr { Scoping.check_reserved_name $3; let stop = expr_to_region $10 in let region = cover $2 stop - and value = {kwd_recursive= $1; + and value = {kwd_recursive= Some($1); kwd_function = $2; fun_name = $3; param = $4; @@ -270,11 +315,11 @@ open_fun_decl: attributes = None} in {region; value} } -| ioption ("recursive") "function" fun_name parameters ":" type_expr "is" expr { +| "recursive" "function" fun_name parameters ":" type_expr "is" expr { Scoping.check_reserved_name $3; let stop = expr_to_region $8 in let region = cover $2 stop - and value = {kwd_recursive= $1; + and value = {kwd_recursive= Some($1); kwd_function = $2; fun_name = $3; param = $4;