Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable λProlog builtins #506

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions elpi-builtin.elpi
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,32 @@ external pred gc.stat o:float, o:float, o:float, o:int, o:int, o:int,
external pred gc.quick-stat o:float, o:float, o:float, o:int, o:int,
o:int, o:int, o:int, o:int, o:int.

% == Lambda Prolog builtins =====================================

% -- Extra I/O --

% [open_string DataIn InStream] opens DataIn as an input stream
external pred open_string i:string, o:in_stream.

% [lookahead InStream NextChar] peeks one byte from InStream
external pred lookahead i:in_stream, o:string.

% -- Hacks --

% [string_to_term S T] parses a term T from S
external pred string_to_term i:string, o:any.

% [readterm InStream T] reads T from InStream, ends with \n
external pred readterm i:in_stream, o:any.

pred printterm i:out_stream, i:A.

printterm S T :- term_to_string T T1, output S T1.

pred read o:A.

read S :- flush std_out, input_line std_in X, string_to_term X S.




1 change: 1 addition & 0 deletions src/coq_elpi_programs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ let elpi_builtins =
elpi_set @
io_builtins @
ocaml_runtime @
lp_builtins @
[]
)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_link_order_import3.ref
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ std.set.private.cardinal (std.set.private.node A0 _ A1 _) A2 :-
std.set.private.elements std.set.private.empty A0 A0.
std.set.private.elements (std.set.private.node A0 A1 A2 _) A3 A4 :-
std.set.private.elements A2 A3 A5 , std.set.private.elements A0 [A1 | A5] A4.
printterm A0 A1 :- term_to_string A1 A2 , output A0 A2.
read A0 :- , (flush std_out) (input_line std_in A1) (string_to_term A1 A0).
p before 2.
p before 22.
p before 1.
Expand Down
Loading