This commit is contained in:
Vitor Santos Costa
2018-07-18 17:36:01 +01:00
parent e5748f3c9f
commit abc11dcfaa
12 changed files with 728 additions and 273 deletions

View File

@@ -1,3 +1,4 @@
/**
* @file jupyter.yap4py
*
@@ -16,10 +17,10 @@
:- use_module(library(lists)).
:- use_module(library(maplist)).
:- use_module(library(python)).
:- use_module(library(yapi)).
:- use_module(library(complete)).
:- use_module(library(verify)).
:- reexport(library(python)).
:- reexport(library(yapi)).
:- reexport(library(complete)).
:- reexport(library(verify)).
:- python_import(sys).

View File

@@ -6,7 +6,7 @@
:- module( verify,
[errors/2,
[errors/2,q
ready/2]
).
:- use_module(library(hacks)).
@@ -22,7 +22,7 @@
ready( Engine, Query) :-
errors( Engine , Cell ),
Es := Engine.errors,
Es == [].
not Es == [].
@@ -30,7 +30,7 @@ errors( _Engine , Text ) :-
blank(Text).
!.
errors( Engine , Text ) :-
b_setval(jupyter, Engine),
jupyter..shell := Engine,
setup_call_cleanup(
open_esh( Engine , Text, Stream, Name ),
esh(Engine , Name, Stream),
@@ -46,23 +46,26 @@ open_esh(Engine , Text, Stream, Name) :-
open_mem_read_stream( Text, Stream ).
esh(Engine , Name, Stream) :-
b_setval(code,python),
repeat,
catch(
read_clause(Stream, Cl,[]),
E=error(C,E),
p_message(C,E)
),
( read_clause(Stream, Cl, [ syntax_errors(fail)]),
writeln(cl:Cl),
error(C,E),
p_message(C,E)
Cl == end_of_file,
!.
user:print_message() :- p_message
close_esh( _Engine , Stream ) :-
b_delete
close(Stream).
p_message(Severity, Error) :-
writeln((Severity->Error)),
catch( b_getval(jupyter, Engine), _, fail ),
p_message(Severity, Engine, Error).
p_message( _Severity, Engine, error(syntax_error(Cause),info(between(_,LN,_), _FileName, CharPos, Details))) :-