diff --git a/src/passes/1-parser/pascaligo/LexToken.mli b/src/passes/1-parser/pascaligo/LexToken.mli index 1f94e166f..d1709f5a8 100644 --- a/src/passes/1-parser/pascaligo/LexToken.mli +++ b/src/passes/1-parser/pascaligo/LexToken.mli @@ -80,6 +80,7 @@ type t = | Down of Region.t (* "down" *) | Else of Region.t (* "else" *) | End of Region.t (* "end" *) +| Expr of Region.t (* "expr" *) | Fail of Region.t (* "fail" *) | For of Region.t (* "for" *) | From of Region.t (* "from" *) diff --git a/src/passes/1-parser/pascaligo/LexToken.mll b/src/passes/1-parser/pascaligo/LexToken.mll index c27abbb12..4ef7b612b 100644 --- a/src/passes/1-parser/pascaligo/LexToken.mll +++ b/src/passes/1-parser/pascaligo/LexToken.mll @@ -78,6 +78,7 @@ type t = | Down of Region.t (* "down" *) | Else of Region.t (* "else" *) | End of Region.t (* "end" *) +| Expr of Region.t (* "expr" *) | Fail of Region.t (* "fail" *) | For of Region.t (* "for" *) | From of Region.t (* "from" *) @@ -210,6 +211,7 @@ let proj_token = function | Down region -> region, "Down" | Else region -> region, "Else" | End region -> region, "End" +| Expr region -> region, "Expr" | Fail region -> region, "Fail" | For region -> region, "For" | From region -> region, "From" @@ -303,6 +305,7 @@ let to_lexeme = function | Down _ -> "down" | Else _ -> "else" | End _ -> "end" +| Expr _ -> "expr" | Fail _ -> "fail" | For _ -> "for" | From _ -> "from" @@ -364,6 +367,7 @@ let keywords = [ (fun reg -> Down reg); (fun reg -> Else reg); (fun reg -> End reg); + (fun reg -> Expr reg); (fun reg -> For reg); (fun reg -> From reg); (fun reg -> Function reg); @@ -588,6 +592,7 @@ let is_kwd = function | Down _ | Else _ | End _ +| Expr _ | Fail _ | For _ | From _ diff --git a/src/passes/1-parser/pascaligo/Parser.mly b/src/passes/1-parser/pascaligo/Parser.mly index bd9f63174..6c367e186 100644 --- a/src/passes/1-parser/pascaligo/Parser.mly +++ b/src/passes/1-parser/pascaligo/Parser.mly @@ -264,6 +264,25 @@ fun_decl: return = $10; terminator = $11} in {region; value}} + | Function fun_name parameters COLON type_expr Is + Expr expr option(SEMI) { + let stop = + match $9 with + Some region -> region + | None -> expr_to_region $8 in + let region = cover $1 stop + and value = { + kwd_function = $1; + name = $2; + param = $3; + colon = $4; + ret_type = $5; + kwd_is = $6; + kwd_expr = $7; + expr = $8; + terminator = $9; + } + in {region; value}} parameters: par(nsepseq(param_decl,SEMI)) { $1 }