-
Notifications
You must be signed in to change notification settings - Fork 2
/
fasill.py
42 lines (40 loc) · 876 Bytes
/
fasill.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from pyswip import Prolog
import curses
def fasill():
pl = Prolog()
pl.consult("src/fasill.pl")
pl.consult("src/parser.pl")
pl.consult("src/environment.pl")
pl.consult("src/resolution.pl")
list(pl.query("initialize([])"))
stdscr = curses.initscr()
stdscr.keypad(True)
stdscr.scrollok(True)
stdscr.clear()
curses.noecho()
i = 0
while True:
goal = ""
i += 1
stdscr.addstr("fasill:%d> " % i)
stdscr.refresh()
c = stdscr.getch()
while c != 10 and c != curses.KEY_ENTER:
goal += unichr(c)
c = stdscr.getch()
stdscr.addstr(goal + "\n")
stdscr.refresh()
query = pl.query("""
atom_chars('%s', Chars),
parse_query(Chars, Goal),
query(Goal, SFCA),
once(print_term(SFCA))
""" % goal)
for answer in query:
stdscr.addstr("\n")
stdscr.refresh()
c = stdscr.getch()
stdscr.keypad(False)
curses.echo()
curses.endwin()
fasill()