Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

prologpipe::PrologPipe Class Reference

List of all members.

Public Member Functions

 __init__ (swipl='/usr/local/bin/swipl-q-tty', blocked=None)
 errorp ()
 readyp ()
 force ()
 force_quit ()
 run_query_once (q)
 run_query (q)
 lastprompt ()
 get_bindings (s=None)
 get_result ()
 finish ()
 _balanced (s)
 _flushall ()
 _close_query ()
 _prep_query (q)
 _alrmhandler (signum, frame)
 _readtoprompt ()
 _readalt (vars)
 _endswp (s)

Detailed Description

Manages a Prolog session transparently over a pipe.


Member Function Documentation

prologpipe::PrologPipe::__init__ swipl  = '/usr/local/bin/swipl-q-tty',
blocked  = None
 

swipl -- the path to SWI-Prolog; it is sensible to append the arguments '-q' and '-tty' for silent output and to tell Prolog that it does not run on a terminal. In fact, please do so unless you have specific reasons for not doing so

blocked -- flag specifying wether 'Error: ** here **' messages from the interpreter should be honoured; don't set to anything other than None (don't block messages) unless you specifically know your code will never be wrong! It saves processor time, but it's not really worth the risk

prologpipe::PrologPipe::_alrmhandler signum  ,
frame 
 

prologpipe::PrologPipe::_balanced  ) 
 

prologpipe::PrologPipe::_close_query  ) 
 

Close a query opened with 'open_query'; note that you MUST call this method in order to avoid bad results and outright crashes!

prologpipe::PrologPipe::_endswp  ) 
 

ends with prompt?

prologpipe::PrologPipe::_flushall  ) 
 

prologpipe::PrologPipe::_prep_query  ) 
 

prologpipe::PrologPipe::_readalt vars   ) 
 

prologpipe::PrologPipe::_readtoprompt  ) 
 

prologpipe::PrologPipe::errorp  ) 
 

Test for non-fatal error in previous Prolog query/queries

prologpipe::PrologPipe::finish  ) 
 

Close the Prolog session; invalidates the object! This will take at least half a second, so make sure cou have the time at the point where you call it

prologpipe::PrologPipe::force  ) 
 

Try to get the interpreter into a sane state - works only on *NIXes for the time being (systems that provide the 'kill' command)

prologpipe::PrologPipe::force_quit  ) 
 

Force quit the Prolog interpreter - works only on *NIXes for the time being (systems that provide the 'kill' command)

prologpipe::PrologPipe::get_bindings = None  ) 
 

Returns the bindings from the last query as a list of tuples (Variable, Binding)

The argument is for internal use only.

prologpipe::PrologPipe::get_result  ) 
 

Returns the result of the last query (Yes or No) as a boolean value (None or not None)

prologpipe::PrologPipe::lastprompt  ) 
 

Returns the current prompt; normally not called by user code, but might be needed in special circumstances; return values can be one of:

PROMPT_QUERY -- the normal Prolog query prompt: ?-

PROMPT_ACTION -- the exception prompt

PROMPT_CONTINUE -- the newline-within-unfinished-query prompt |

prologpipe::PrologPipe::readyp  ) 
 

Test for interpreter readiness - use this if you need to see if something went wrong with the last query

prologpipe::PrologPipe::run_query  ) 
 

Open a query and start generating results. Note that open_query only takes arguments that are legal arguments to call/1; you must not end the query with a full stop!

This method requires the 'sets' module introduced in Python 2.3, or an equivalent module supplying the main facilities of 'sets'.

Results are the same as the results from get_bindings()

Use e.g. as in the following example: for result in l.run_query('( A=2 ; A=3 )'): print dict(result)['A']

prologpipe::PrologPipe::run_query_once  ) 
 

Run a query as with 'once/1'; if you need more than one result, and still use this method. you'll have to run a query with - e.g. - 'findall/3'


The documentation for this class was generated from the following file:
Generated on Tue Jul 19 23:31:00 2005 for WoWi by  doxygen 1.3.9.1