This commit is contained in:
Vitor Santos Costa 2019-03-27 11:01:55 +00:00
parent c0f7dfe3c3
commit 7383ff79cc

View File

@ -661,7 +661,7 @@ class YAPRun(InteractiveShell):
self.cell_name = str( self.shell.execution_count) self.cell_name = str( self.shell.execution_count)
self.shell.displayhook.exec_result= result self.shell.displayhook.exec_result= result
cell = raw_cell.strip() cell = raw_cell.strip()
while cell[0] == '%': while cell and cell[0] == '%':
if cell[1] == '%': if cell[1] == '%':
## cell magic ## cell magic
txt0 = cell[2:].split(maxsplit = 1, sep = '\n') txt0 = cell[2:].split(maxsplit = 1, sep = '\n')
@ -756,6 +756,10 @@ class YAPRun(InteractiveShell):
def prolog_cell(self, s): def prolog_cell(self, s):
return pcell(s)
def pcell(s):
""" """
Trasform a text into program+query. A query is the Trasform a text into program+query. A query is the
last line if the last line is non-empty and does not terminate last line if the last line is non-empty and does not terminate
@ -788,28 +792,23 @@ class YAPRun(InteractiveShell):
query = line+'\n\n'+query query = line+'\n\n'+query
i+=1 i+=1
reps = 1 reps = 1
loop = ''
if query: if query:
q = query.strip() q = query.strip()
c= q.rpartition('*')
c2 = c[2].strip()
if c[1] != '*' or (c2!='' and not c2.isdecimal()):
c = q.rpartition('?') c = q.rpartition('?')
c2 = c[2].strip() c2 = c[2].strip()
if c[1] == '?' and(c2=='' or c2.isdecimal()): if c[1] == '?' and(c2=='' or c2.isdecimal()):
c = q.rpartition(';') c = q.rpartition(';')
c2 = c[2].strip() c2 = c[2].strip()
else: else:
c=('','',query) c=(query,'','')
[q,loop,repeats] = c [q,loop,repeats] = c
if q: if q:
query=q query=q
if repeats.strip().isdecimal(): if repeats.strip().isdecimal():
reps = int(repeats) reps = int(repeats)
sep = sepator
elif loop == '*':
reps = -1
elif loop == '?': elif loop == '?':
reps = 10 reps = 10000000
while i<l: while i<l:
line = sl[-i-1] line = sl[-i-1]
if line.strip() != '': if line.strip() != '':
@ -818,7 +817,7 @@ class YAPRun(InteractiveShell):
program = '' program = ''
while i<l: while i<l:
line = sl[-i-1] line = sl[-i-1]
program = line+'\n\n'+program program = line+'\n'+program
i+=1 i+=1
return (program, query, loop, reps) return (program, query, loop, reps)
except Exception as e: except Exception as e:
@ -828,3 +827,4 @@ class YAPRun(InteractiveShell):
except: except:
print(e) print(e)