This commit is contained in:
Vitor Santos Costa
2018-07-27 11:11:04 +01:00
parent 436f1c205a
commit bf712034a9
18 changed files with 333 additions and 249 deletions

View File

@@ -413,11 +413,23 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kerne
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/kernel.js
)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/meta.js
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/misc/editors/meta.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/
DEPENDS ${CMAKE_SOURCE_DIR}/misc/editors/meta.js
)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/misc/editors/yap.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js
DEPENDS ${CMAKE_SOURCE_DIR}/misc/editors/yap.js
)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/mode.js
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/misc/editors/mode.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/
DEPENDS ${CMAKE_SOURCE_DIR}/misc/editors/mode.js
)
foreach(f ${FILES})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${f}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${f} ${CMAKE_CURRENT_BINARY_DIR}/${f}
@@ -431,7 +443,7 @@ endforeach()
add_custom_target(YAP_KERNEL ALL
COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build sdist bdist
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-32x32.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-64x64.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kernel.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js ${OUTS} YAP4PY
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-32x32.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/logo-64x64.png ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/kernel.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/meta.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/prolog.js ${CMAKE_CURRENT_BINARY_DIR}/yap_kernel/resources/mode.js ${OUTS} YAP4PY
)

View File

@@ -92,9 +92,9 @@ blank(Text) :-
close(user_output),
close(user_error).
streams(true) :-
open('/python/input', read, Input, [alias(user_input),bom(false),script(false)]),
open('/python/sys.stdout', append, Output, [alias(user_output)]),
open('/python/sys.stderr', append, Error, [alias(user_error)]).
open('/python/sys.stdin', read, _Input, [alias(user_input),bom(false),script(false)]),
open('/python/sys.stdout', append, _Output, [alias(user_output)]),
open('/python/sys.stderr', append, _Error, [alias(user_error)]).
:- if( current_prolog_flag(apple, true) ).

View File

@@ -514,6 +514,7 @@ class YAPRun:
self.yapeng = JupyterEngine()
global engine
engine = self.yapeng
self.errors = []
self.query = None
self.os = None
self.it = None
@@ -577,7 +578,7 @@ class YAPRun:
self.iterations += 1
if self.port == "exit":
self.os = None
sys.stderr.write('Done, with'+str(self.answers)+'\n')
#sys.stderr.write('Done, with'+str(self.answers)+'\n')
self.result.result = True,self.bindings
return self.result
if stop or howmany == self.iterations:
@@ -658,7 +659,7 @@ class YAPRun:
if store_history:
self.result.execution_count = self.shell.execution_count+1
def error_before_exec(value):
def error_before_exec(self, value):
self.result.error_before_exec = value
self.shell.last_execution_succeeded = False
return self.result
@@ -677,10 +678,10 @@ class YAPRun:
# except SyntaxError:
# preprocessing_exc_tuple = self.shell.syntax_error() # sys.exc_info()
cell = raw_cell # cell has to exist so it can be stored/logged
for i in self.syntaxErrors(raw_cell):
for i in self.errors:
try:
(what,lin,_,text) = i
e = SyntaxError(what, ("<string>", lin, 1, text+'\n'))
(_,lin,pos,text) = i
e = SyntaxError(what, (self.cell_name, lin, pos, text+'\n'))
raise e
except SyntaxError:
self.shell.showsyntaxerror( )
@@ -696,13 +697,13 @@ class YAPRun:
self.showtraceback(preprocessing_exc_tuple)
if store_history:
self.shell.execution_count += 1
return error_before_exec(preprocessing_exc_tuple[2])
return self.error_before_exec(preprocessing_exc_tuple[2])
# Our own compiler remembers the __future__ environment. If we want to
# run code with a separate __future__ environment, use the default
# compiler
# compiler = self.shell.compile if shell_futures else CachingCompiler()
cell_name = str( self.shell.execution_count)
self.cell_name = str( self.shell.execution_count)
if cell[0] == '%':
if cell[1] == '%':
linec = False
@@ -802,7 +803,7 @@ class YAPRun:
its = 0
for ch in n:
if not ch.isdigit():
raise SyntaxError()
raise SyntaxError("expected positive number", (self.cellname,s.strip.lines()+1,s.count('\n'),n))
its = its*10+ (ord(ch) - ord('0'))
stop = False
else: