Skip to content

Commit fbc7334

Browse files
authored
Merge pull request #114 from LPCIC/cleanup
Cleanup before tackling tabling
2 parents 102f807 + ac7fcd4 commit fbc7334

File tree

13 files changed

+334
-286
lines changed

13 files changed

+334
-286
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
- Runtime/FFI:
44
- fix handling of eta expanded unification variables. Many thanks to
55
Nathan Guermond for testing this tricky case.
6+
- Change `Rawdata.Constants.eqc` to a builtin
7+
- Fix `Rawdata.Constants.cutc` has always been a builtin
68

79
# v1.13.7 (July 2021)
810

elpi_REPL.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ let usage =
6161
"\t-no-tc don't typecheck the program\n" ^
6262
"\t-delay-problems-outside-pattern-fragment (deprecated, for Teyjus\n" ^
6363
"\t compatibility)\n" ^
64-
"\t-version prints the version of Elpi\n" ^
64+
"\t--version prints the version of Elpi (also -v or -version)\n" ^
65+
"\t--help prints this help (also -h or -help)\n" ^
6566
API.Setup.usage ^
6667
"\nDebug options (for debugging Elpi, not your program):\n" ^
6768
"\t-print-accumulated-files prints files loaded via accumulate\n" ^
@@ -103,8 +104,8 @@ let _ =
103104
| "-no-tc" :: rest -> typecheck := false; eat_options rest
104105
| "-document-builtins" :: rest -> doc_builtins := true; eat_options rest
105106
| "-D" :: var :: rest -> vars := API.Compile.StrSet.add var !vars; eat_options rest
106-
| ("-h" | "--help") :: _ -> Printf.eprintf "%s" usage; exit 0
107-
| "-version" :: _ -> Printf.printf "%s\n" "%%VERSION_NUM%%"; exit 0
107+
| ("-h" | "--help" | "-help") :: _ -> Printf.eprintf "%s" usage; exit 0
108+
| ("-v" | "--version" | "-version") :: _ -> Printf.printf "%s\n" "%%VERSION_NUM%%"; exit 0
108109
| "--" :: rest -> rest
109110
| x :: rest -> x :: eat_options rest
110111
in

src/API.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ end
176176
module Pp = struct
177177
let term pp_ctx f t = (* XXX query depth *)
178178
let module R = (val !r) in let open R in
179-
R.Pp.uppterm ~pp_ctx 0 [] 0 [||] f t
179+
R.Pp.uppterm ~pp_ctx 0 [] ~argsdepth:0 [||] f t
180180

181181
let constraints pp_ctx f c =
182182
let module R = (val !r) in let open R in
@@ -186,7 +186,7 @@ module Pp = struct
186186

187187
let query f c =
188188
let module R = (val !r) in let open R in
189-
Compiler.pp_query (fun ~pp_ctx ~depth -> R.Pp.uppterm ~pp_ctx depth [] 0 [||]) f c
189+
Compiler.pp_query (fun ~pp_ctx ~depth -> R.Pp.uppterm ~pp_ctx depth [] ~argsdepth:0 [||]) f c
190190

191191
module Ast = struct
192192
let program = EA.Program.pp

src/API.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,14 +954,14 @@ module RawData : sig
954954

955955
val show : constant -> string
956956

957-
val eqc : constant (* = *)
957+
val eqc : builtin (* = *)
958958
val orc : constant (* ; *)
959959
val andc : constant (* , *)
960960
val rimplc : constant (* :- *)
961961
val pic : constant (* pi *)
962962
val sigmac : constant (* sigma *)
963963
val implc : constant (* => *)
964-
val cutc : constant (* ! *)
964+
val cutc : builtin (* ! *)
965965

966966
(* LambdaProlog built-in data types are just instances of CData.
967967
* The typeabbrev machinery translates [int], [float] and [string]

src/builtin.elpi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ pred fail.
1212

1313
pred false.
1414

15-
pred (=) o:A, o:A.
16-
17-
X = X.
15+
external pred (=) o:A, o:A. % unification
1816

1917
typeabbrev int (ctype "int").
2018

@@ -512,7 +510,7 @@ external pred random.int i:int, o:int.
512510
% Conventions:
513511
% - all predicates declare a mode with some input arguments, unless...
514512
% - predicates whose name ends with R are relations (work in any direction,
515-
% that is all arguments are in ouput mode)
513+
% that is all arguments are in output mode)
516514
% - predicates whose name ends with ! do contain a cut and generate only the
517515
% first result
518516
% - all errors given by this library end up calling fatal-error[-w-data],

src/builtin.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,8 @@ let core_builtins = let open BuiltIn in let open ContextualConversion in [
395395
LPCode "pred fail.";
396396
LPCode "pred false.";
397397

398-
LPCode "pred (=) o:A, o:A.";
399-
LPCode "X = X.";
400-
398+
LPCode "external pred (=) o:A, o:A. % unification";
399+
401400
MLData BuiltInData.int;
402401
MLData BuiltInData.string;
403402
MLData BuiltInData.float;

src/builtin_stdlib.elpi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
% Conventions:
44
% - all predicates declare a mode with some input arguments, unless...
55
% - predicates whose name ends with R are relations (work in any direction,
6-
% that is all arguments are in ouput mode)
6+
% that is all arguments are in output mode)
77
% - predicates whose name ends with ! do contain a cut and generate only the
88
% first result
99
% - all errors given by this library end up calling fatal-error[-w-data],

src/compiler.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ let is_declared_str state x =
312312
|| x == Symbols.(show state D.Global_symbols.declare_constraintc)
313313
|| x == Symbols.(show state D.Global_symbols.print_constraintsc)
314314
|| x == Symbols.(show state D.Global_symbols.cutc)
315+
|| x == Symbols.(show state D.Global_symbols.eqc)
315316
|| x == Symbols.(show state D.Global_symbols.findall_solutionsc)
316317
;;
317318

@@ -321,6 +322,7 @@ let is_declared state x =
321322
|| x == D.Global_symbols.declare_constraintc
322323
|| x == D.Global_symbols.print_constraintsc
323324
|| x == D.Global_symbols.cutc
325+
|| x == D.Global_symbols.eqc
324326
|| x == D.Global_symbols.findall_solutionsc
325327
;;
326328

@@ -2128,7 +2130,7 @@ let query_of_ast (compiler_state, assembled_program) t =
21282130
let query_env = Array.make query.amap.nargs D.dummy in
21292131
let state, queryt = stack_term_of_preterm ~depth:initial_depth state query in
21302132
let initial_goal =
2131-
R.move ~adepth:initial_depth ~from:initial_depth ~to_:initial_depth query_env
2133+
R.move ~argsdepth:initial_depth ~from:initial_depth ~to_:initial_depth query_env
21322134
queryt in
21332135
let assignments = StrMap.map (fun i -> query_env.(i)) query.amap.n2i in
21342136
{
@@ -2159,7 +2161,7 @@ let query_of_term (compiler_state, assembled_program) f =
21592161
let query_env = Array.make query.amap.nargs D.dummy in
21602162
let state, queryt = stack_term_of_preterm ~depth:initial_depth state query in
21612163
let initial_goal =
2162-
R.move ~adepth:initial_depth ~from:initial_depth ~to_:initial_depth query_env
2164+
R.move ~argsdepth:initial_depth ~from:initial_depth ~to_:initial_depth query_env
21632165
queryt in
21642166
let assignments = StrMap.map (fun i -> query_env.(i)) query.amap.n2i in
21652167
{
@@ -2533,7 +2535,7 @@ let term_of_ast ~depth state t =
25332535
) state t in
25342536
let env = Array.make nargs D.dummy in
25352537
let argsdepth = depth in
2536-
state, R.move ~adepth:argsdepth ~from:depth ~to_:depth env t
2538+
state, R.move ~argsdepth ~from:depth ~to_:depth env t
25372539
;;
25382540

25392541
let static_check ~exec ~checker:(state,program)

0 commit comments

Comments
 (0)