From f0262bf843c8ef6ca2ad4d12ee6f82c8032e6857 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Wed, 17 Apr 2024 14:30:27 +0200 Subject: fix(backends/lean): `as` is a keyword `as` is a reserved keyword and cannot be used as a variable name. Fixes #139. Signed-off-by: Ryan Lahfa --- compiler/ExtractBase.ml | 1 + 1 file changed, 1 insertion(+) (limited to 'compiler/ExtractBase.ml') diff --git a/compiler/ExtractBase.ml b/compiler/ExtractBase.ml index 656d2f27..718325d2 100644 --- a/compiler/ExtractBase.ml +++ b/compiler/ExtractBase.ml @@ -915,6 +915,7 @@ let keywords () = ] | Lean -> [ + "as"; "by"; "class"; "decreasing_by"; -- cgit v1.2.3 From 67502f5530b42b11e8580c8464c220664afb4ec4 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Wed, 17 Apr 2024 17:21:08 +0200 Subject: fix(backends/lean): `from` is a keyword Signed-off-by: Ryan Lahfa --- compiler/ExtractBase.ml | 1 + 1 file changed, 1 insertion(+) (limited to 'compiler/ExtractBase.ml') diff --git a/compiler/ExtractBase.ml b/compiler/ExtractBase.ml index 718325d2..40423cb5 100644 --- a/compiler/ExtractBase.ml +++ b/compiler/ExtractBase.ml @@ -941,6 +941,7 @@ let keywords () = "simp"; "structure"; "syntax"; + "from"; "termination_by"; "then"; "Type"; -- cgit v1.2.3 From 905ec4f1d62734af956fd54e2aa3872e3c8a8e09 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Wed, 17 Apr 2024 17:21:30 +0200 Subject: chore(backends/lean): sort the keyword list OCD. :D Signed-off-by: Ryan Lahfa --- compiler/ExtractBase.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'compiler/ExtractBase.ml') diff --git a/compiler/ExtractBase.ml b/compiler/ExtractBase.ml index 40423cb5..92206ece 100644 --- a/compiler/ExtractBase.ml +++ b/compiler/ExtractBase.ml @@ -915,6 +915,7 @@ let keywords () = ] | Lean -> [ + "Type"; "as"; "by"; "class"; @@ -925,30 +926,29 @@ let keywords () = "else"; "end"; "for"; + "from"; "have"; "if"; + "import"; "inductive"; "instance"; - "import"; "let"; "macro"; "match"; "namespace"; "opaque"; + "opaque_defs"; "open"; "run_cmd"; "set_option"; "simp"; "structure"; "syntax"; - "from"; "termination_by"; "then"; - "Type"; "unsafe"; "where"; "with"; - "opaque_defs"; ] | HOL4 -> [ -- cgit v1.2.3 From fa57d8d9d51c93ccefefb0951c67475970e97879 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 8 Apr 2024 15:18:58 +0200 Subject: item_meta --- compiler/ExtractBase.ml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'compiler/ExtractBase.ml') diff --git a/compiler/ExtractBase.ml b/compiler/ExtractBase.ml index 656d2f27..8080e08c 100644 --- a/compiler/ExtractBase.ml +++ b/compiler/ExtractBase.ml @@ -1932,10 +1932,11 @@ let ctx_add_global_decl_and_body (def : A.global_decl) (ctx : extraction_ctx) : match match_name_find_opt ctx.trans_ctx def.name builtin_globals_map with | Some name -> (* Yes: register the custom binding *) - ctx_add def.meta decl name ctx + ctx_add def.item_meta.meta decl name ctx | None -> (* Not the case: "standard" registration *) - let name = ctx_compute_global_name def.meta ctx def.name in + let name = ctx_compute_global_name def.item_meta.meta ctx def.name in + let body = FunId (FromLlbc (FunId (FRegular def.body), None)) in (* If this is a provided constant (i.e., the default value for a constant in a trait declaration) we add a suffix. Otherwise there is a clash @@ -1944,8 +1945,8 @@ let ctx_add_global_decl_and_body (def : A.global_decl) (ctx : extraction_ctx) : let suffix = match def.kind with TraitItemProvided _ -> "_default" | _ -> "" in - let ctx = ctx_add def.meta decl (name ^ suffix) ctx in - let ctx = ctx_add def.meta body (name ^ suffix ^ "_body") ctx in + let ctx = ctx_add def.item_meta.meta decl (name ^ suffix) ctx in + let ctx = ctx_add def.item_meta.meta body (name ^ suffix ^ "_body") ctx in ctx let ctx_compute_fun_name (def : fun_decl) (ctx : extraction_ctx) : string = -- cgit v1.2.3 From bc808d128811396de40eb251528640e127f83fad Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Wed, 17 Apr 2024 17:29:38 +0200 Subject: fix(backends/lean): extract more keywords from `lstlean.latex` Taken from https://github.com/leanprover/lean4/blob/master/doc/latex/lstlean.tex#L12 and sorted. Tactics are ignored. Signed-off-by: Ryan Lahfa --- compiler/ExtractBase.ml | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'compiler/ExtractBase.ml') diff --git a/compiler/ExtractBase.ml b/compiler/ExtractBase.ml index 92206ece..ddffb1c2 100644 --- a/compiler/ExtractBase.ml +++ b/compiler/ExtractBase.ml @@ -915,38 +915,100 @@ let keywords () = ] | Lean -> [ + "Pi"; "Type"; + "abbrev"; + "alias"; "as"; + "at"; + "attribute"; + "axiom"; + "axioms"; + "begin"; + "break"; "by"; + "calc"; + "catch"; "class"; + "const"; + "constant"; + "constants"; + "continue"; "decreasing_by"; "def"; + "definition"; "deriving"; "do"; "else"; "end"; + "example"; + "exists"; + "export"; + "extends"; "for"; + "forall"; "from"; + "fun"; "have"; + "hiding"; "if"; "import"; + "in"; + "include"; "inductive"; + "infix"; + "infixl"; + "infixr"; "instance"; + "lemma"; "let"; + "local"; "macro"; + "macro_rules"; "match"; + "mut"; + "mutual"; "namespace"; + "noncomputable"; + "notation"; + "omit"; "opaque"; "opaque_defs"; "open"; + "override"; + "parameter"; + "parameters"; + "partial"; + "postfix"; + "precedence"; + "prefix"; + "prelude"; + "private"; + "protected"; + "raw"; + "record"; + "reduce"; + "renaming"; + "replacing"; + "reserve"; "run_cmd"; + "section"; "set_option"; "simp"; "structure"; "syntax"; "termination_by"; "then"; + "theorem"; + "theory"; + "universe"; + "universes"; + "unless"; "unsafe"; + "using"; + "using_well_founded"; + "variable"; + "variables"; "where"; "with"; ] -- cgit v1.2.3 From 00fb0b9dee66a5ba012170c3313454934c976d5e Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Wed, 17 Apr 2024 17:35:13 +0200 Subject: fix(backends/lean): extract more keywords from `lstlean.tex` Taken from https://github.com/leanprover/lean4/blob/master/doc/latex/lstlean.tex#L33 and https://github.com/leanprover/lean4/blob/master/doc/latex/lstlean.tex#L36-L43. This will not extract the tactics. Signed-off-by: Ryan Lahfa --- compiler/ExtractBase.ml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'compiler/ExtractBase.ml') diff --git a/compiler/ExtractBase.ml b/compiler/ExtractBase.ml index ddffb1c2..e30c4b36 100644 --- a/compiler/ExtractBase.ml +++ b/compiler/ExtractBase.ml @@ -916,6 +916,8 @@ let keywords () = | Lean -> [ "Pi"; + "Prop"; + "Sort"; "Type"; "abbrev"; "alias"; -- cgit v1.2.3