Make all python code compatible with Python 2.x and Python 3.x.
* wrap/python/buddy.i (__le__, __lt__, __eq__, __ne__, __ge__ __gt__): New operators for bdd. * wrap/python/spot.i (__le__, __lt__, __eq__, __ne__, __ge__ __gt__, __hash__): New operators for formula. (nl_cout, nl_cerr): New functions. * wrap/python/tests/bddnqueen.py, wrap/python/tests/interdep.py, wrap/python/tests/ltl2tgba.py, wrap/python/tests/ltlparse.py, wrap/python/tests/ltlsimple.py, wrap/python/tests/minato.py, wrap/python/tests/modgray.py: Adjust to the new print syntax by using sys.output.write() or nl_cout() instead. * wrap/python/tests/optionmap.py: Remove all print calls. * wrap/python/ajax/spot.in: Massive adjustments in order to work with both Python 2 and 3. In python 3, reopening stdout as unbuffered requires it to be open as binary, which in turns requires any string output to be encoded manually. BaseHTTPServer and CGIHTTPServer have been merged into http.server, so we have to try two different import syntaxes. execfile no longer exists, so it has to be emulated. This also fixes two bugs where the script would segfault on empty input, or when calling Tau03 on automata with less then one acceptance conditions.
This commit is contained in:
parent
5e77b2498a
commit
61127a3fd5
12 changed files with 262 additions and 155 deletions
27
ChangeLog
27
ChangeLog
|
|
@ -1,3 +1,30 @@
|
||||||
|
2012-02-25 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
|
Make all python code compatible with Python 2.x and Python 3.x.
|
||||||
|
|
||||||
|
* wrap/python/buddy.i (__le__, __lt__, __eq__, __ne__, __ge__
|
||||||
|
__gt__): New operators for bdd.
|
||||||
|
* wrap/python/spot.i (__le__, __lt__, __eq__, __ne__, __ge__
|
||||||
|
__gt__, __hash__): New operators for formula.
|
||||||
|
(nl_cout, nl_cerr): New functions.
|
||||||
|
* wrap/python/tests/bddnqueen.py,
|
||||||
|
wrap/python/tests/interdep.py, wrap/python/tests/ltl2tgba.py,
|
||||||
|
wrap/python/tests/ltlparse.py, wrap/python/tests/ltlsimple.py,
|
||||||
|
wrap/python/tests/minato.py, wrap/python/tests/modgray.py: Adjust
|
||||||
|
to the new print syntax by using sys.output.write() or nl_cout()
|
||||||
|
instead.
|
||||||
|
* wrap/python/tests/optionmap.py: Remove all print calls.
|
||||||
|
* wrap/python/ajax/spot.in: Massive adjustments in order to work
|
||||||
|
with both Python 2 and 3. In python 3, reopening stdout as
|
||||||
|
unbuffered requires it to be open as binary, which in turns
|
||||||
|
requires any string output to be encoded manually. BaseHTTPServer
|
||||||
|
and CGIHTTPServer have been merged into http.server, so we have
|
||||||
|
to try two different import syntaxes. execfile no longer exists,
|
||||||
|
so it has to be emulated.
|
||||||
|
This also fixes two bugs where the script would segfault on
|
||||||
|
empty input, or when calling Tau03 on automata with less then
|
||||||
|
one acceptance conditions.
|
||||||
|
|
||||||
2012-02-24 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
2012-02-24 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
Fix computation of PYTHONINC for Python 3.
|
Fix computation of PYTHONINC for Python 3.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!@PYTHON@
|
#!@PYTHON@
|
||||||
# -*- mode: python; coding: iso-8859-1 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement
|
# Copyright (C) 2011, 2012 Laboratoire de Recherche et Développement
|
||||||
# de l'Epita (LRDE).
|
# de l'Epita (LRDE).
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -21,13 +21,16 @@
|
||||||
# 02111-1307, USA.
|
# 02111-1307, USA.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
script = os.environ.has_key('SCRIPT_NAME')
|
script = ('SCRIPT_NAME' in os.environ)
|
||||||
|
|
||||||
if script:
|
if script:
|
||||||
print "Cache-Control: max-age=3600" # One hour.
|
# 3600s = 1h
|
||||||
print "Content-Type: text/html"
|
sys.stdout.write("""Cache-Control: max-age=3600
|
||||||
print
|
Content-Type: text/html
|
||||||
|
|
||||||
|
""")
|
||||||
|
|
||||||
# Directory for temporary files (images and other auxiliary files).
|
# Directory for temporary files (images and other auxiliary files).
|
||||||
imgdir = 'spotimg'
|
imgdir = 'spotimg'
|
||||||
|
|
@ -37,12 +40,17 @@ qs = os.getenv('QUERY_STRING')
|
||||||
if qs:
|
if qs:
|
||||||
import hashlib
|
import hashlib
|
||||||
# We (optimistically) assume no collision from sha1(qs)
|
# We (optimistically) assume no collision from sha1(qs)
|
||||||
cachedir = imgdir + '/' + hashlib.sha1(qs).hexdigest()
|
cachedir = imgdir + '/' + hashlib.sha1(qs.encode('utf-8')).hexdigest()
|
||||||
cachename = cachedir + '/html'
|
cachename = cachedir + '/html'
|
||||||
try:
|
try:
|
||||||
# Is this a request we have already processed?
|
# Is this a request we have already processed?
|
||||||
cache = open(cachename, "r", 0)
|
cache = open(cachename, "rb", 0)
|
||||||
print cache.read()
|
if hasattr(sys.stdout, 'buffer'):
|
||||||
|
# Python 3+
|
||||||
|
sys.stdout.buffer.write(cache.read())
|
||||||
|
else:
|
||||||
|
# Python 2.x
|
||||||
|
sys.stdout.write(cache.read())
|
||||||
# Touch the directory containing the files we used, so
|
# Touch the directory containing the files we used, so
|
||||||
# it that it survives the browser's cache.
|
# it that it survives the browser's cache.
|
||||||
os.utime(cachedir, None)
|
os.utime(cachedir, None)
|
||||||
|
|
@ -52,7 +60,7 @@ if qs:
|
||||||
# Let's run the rest of the script to create it.
|
# Let's run the rest of the script to create it.
|
||||||
pass
|
pass
|
||||||
elif script:
|
elif script:
|
||||||
print "<b>QUERY_STRING unset!</b>"
|
sys.stdout.write("<b>QUERY_STRING unset!</b>\n")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Location of the dot command
|
# Location of the dot command
|
||||||
|
|
@ -64,26 +72,33 @@ svg_output = False # FIXME: SVG output seems to be working well with
|
||||||
# to get the correct size and transparent
|
# to get the correct size and transparent
|
||||||
# background in Chrome.
|
# background in Chrome.
|
||||||
|
|
||||||
from CGIHTTPServer import CGIHTTPRequestHandler
|
|
||||||
class MyHandler(CGIHTTPRequestHandler):
|
|
||||||
def is_cgi(self):
|
|
||||||
if self.path.startswith('/cgi-bin/spot.py'):
|
|
||||||
self.cgi_info = '', self.path[9:]
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
if not script:
|
if not script:
|
||||||
# If this is not run as a cgi script, let's start an HTTP server.
|
# If this is not run as a cgi script, let's start an HTTP server.
|
||||||
from BaseHTTPServer import HTTPServer
|
try:
|
||||||
|
# Python 3+
|
||||||
|
from http.server import CGIHTTPRequestHandler, HTTPServer
|
||||||
|
except ImportError:
|
||||||
|
# Python 2.x
|
||||||
|
from CGIHTTPServer import CGIHTTPRequestHandler
|
||||||
|
from BaseHTTPServer import HTTPServer
|
||||||
|
|
||||||
|
class MyHandler(CGIHTTPRequestHandler):
|
||||||
|
def is_cgi(self):
|
||||||
|
if self.path.startswith('/cgi-bin/spot.py'):
|
||||||
|
self.cgi_info = '', self.path[9:]
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
server_address=('',8000)
|
server_address=('',8000)
|
||||||
if not os.access(imgdir, os.F_OK):
|
if not os.access(imgdir, os.F_OK):
|
||||||
os.mkdir(imgdir, 0755)
|
# 493 = 0755 but we would have to write 0755 or 0o755
|
||||||
print "Directory spotimg/ created."
|
# depending on the python version...
|
||||||
|
os.mkdir(imgdir, 493)
|
||||||
|
sys.stdout.write("Directory spotimg/ created.\n")
|
||||||
httpd = HTTPServer(server_address, MyHandler)
|
httpd = HTTPServer(server_address, MyHandler)
|
||||||
print "Point your browser to http://localhost:8000/ltl2tgba.html"
|
sys.stdout.write("Point your browser to http://localhost:8000/ltl2tgba.html\n")
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|
||||||
import sys
|
|
||||||
import cgi
|
import cgi
|
||||||
import cgitb; cgitb.enable()
|
import cgitb; cgitb.enable()
|
||||||
import signal
|
import signal
|
||||||
|
|
@ -97,25 +112,34 @@ cachename = tmpdir + '/html'
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
# Reopen stdout without buffering
|
# Reopen stdout without buffering
|
||||||
sys.stdout = os.fdopen(sys.stdout.fileno(), "w", 0)
|
sys.stdout = os.fdopen(sys.stdout.fileno(), "wb", 0)
|
||||||
|
|
||||||
# Redirect stderr to stdout at a low level (so that
|
# Redirect stderr to stdout at a low level (so that
|
||||||
# even errors from subprocesses get printed).
|
# even errors from subprocesses get printed).
|
||||||
os.dup2(sys.stdout.fileno(), sys.stderr.fileno())
|
os.dup2(sys.stdout.fileno(), sys.stderr.fileno())
|
||||||
|
|
||||||
# Create the temporary cache directory
|
# Create the temporary cache directory
|
||||||
os.mkdir(tmpdir, 0755)
|
os.mkdir(tmpdir, 493) # See comment above about 0o755 or 0755.
|
||||||
|
|
||||||
# Redirect stdout to the cache file, at a low level
|
# Redirect stdout to the cache file, at a low level
|
||||||
# for similar reason.
|
# for similar reason.
|
||||||
fd = os.open(cachename, os.O_CREAT | os.O_WRONLY, 0644)
|
fd = os.open(cachename, os.O_CREAT | os.O_WRONLY, 420) # 420 = 0644
|
||||||
os.dup2(fd, sys.stdout.fileno())
|
os.dup2(fd, sys.stdout.fileno())
|
||||||
|
|
||||||
|
# We had to reopen stdout in binary mode to enable unbuffered output,
|
||||||
|
# (disallowed on text I/O by Python 3.x) so starting now, we are not
|
||||||
|
# allowed to send strings to sys.stdout. Always use the following
|
||||||
|
# method instead.
|
||||||
|
def unbufprint(s):
|
||||||
|
sys.stdout.write(s.encode("utf-8"))
|
||||||
|
|
||||||
|
|
||||||
def finish(kill = False):
|
def finish(kill = False):
|
||||||
# Output the result and exit.
|
# Output the result and exit.
|
||||||
os.dup2(sys.stderr.fileno(), sys.stdout.fileno())
|
os.dup2(sys.stderr.fileno(), sys.stdout.fileno())
|
||||||
cache = open(cachename, "r", 0)
|
|
||||||
print cache.read()
|
cache = open(cachename, "rb", 0)
|
||||||
|
sys.stdout.write(cache.read())
|
||||||
|
|
||||||
# Rename tmpdir to its permanent name for caching purpose.
|
# Rename tmpdir to its permanent name for caching purpose.
|
||||||
# os.rename will fail if cachedir already exist. Since we tested
|
# os.rename will fail if cachedir already exist. Since we tested
|
||||||
|
|
@ -131,6 +155,7 @@ def finish(kill = False):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if kill:
|
if kill:
|
||||||
|
# Kill all children
|
||||||
os.kill(0, signal.SIGTERM)
|
os.kill(0, signal.SIGTERM)
|
||||||
# Should we prune the cache?
|
# Should we prune the cache?
|
||||||
stamp = imgdir + '/cache.stamp'
|
stamp = imgdir + '/cache.stamp'
|
||||||
|
|
@ -140,6 +165,8 @@ def finish(kill = False):
|
||||||
if now - os.path.getmtime(stamp) < 3600:
|
if now - os.path.getmtime(stamp) < 3600:
|
||||||
exit(0)
|
exit(0)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
# It's OK if the file did not exist.
|
||||||
|
# We will create it.
|
||||||
pass
|
pass
|
||||||
# Erase all directories that are older than 2 hours, and all
|
# Erase all directories that are older than 2 hours, and all
|
||||||
# files that have only one hardlinks. Files that have more than
|
# files that have only one hardlinks. Files that have more than
|
||||||
|
|
@ -148,14 +175,14 @@ def finish(kill = False):
|
||||||
os.system('find ' + imgdir + ' -mindepth 1 -maxdepth 1 -mmin +120 '
|
os.system('find ' + imgdir + ' -mindepth 1 -maxdepth 1 -mmin +120 '
|
||||||
+ '\( -type d -o -links 1 \) -exec rm -rf {} +')
|
+ '\( -type d -o -links 1 \) -exec rm -rf {} +')
|
||||||
# Create or update the stamp so we know when to run the next prune.
|
# Create or update the stamp so we know when to run the next prune.
|
||||||
open(stamp, "w", 0)
|
open(stamp, "wb", 0)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Assume Spot is installed
|
# Assume Spot is installed
|
||||||
sys.path.insert(0, '@pythondir@')
|
sys.path.insert(0, '@pythondir@')
|
||||||
|
|
||||||
if (os.environ.has_key('SERVER_SOFTWARE') and
|
if ('SERVER_SOFTWARE' in os.environ and
|
||||||
os.environ['SERVER_SOFTWARE'].startswith(MyHandler.server_version)):
|
os.environ['SERVER_SOFTWARE'].startswith('SimpleHTTP')):
|
||||||
# We might be running from the build tree (but it's not sure).
|
# We might be running from the build tree (but it's not sure).
|
||||||
# Add the build and source directories first in the search path.
|
# Add the build and source directories first in the search path.
|
||||||
# If we are not in the right place, python will find the installed
|
# If we are not in the right place, python will find the installed
|
||||||
|
|
@ -171,7 +198,9 @@ if (os.environ.has_key('SERVER_SOFTWARE') and
|
||||||
os.environ['DYLD_LIBRARY_PATH'] = m
|
os.environ['DYLD_LIBRARY_PATH'] = m
|
||||||
|
|
||||||
try:
|
try:
|
||||||
execfile('ltl2tgba.opt')
|
# execfile('ltl2tgba.opt') no longuer work with Python 3.
|
||||||
|
exec(compile(open("ltl2tgba.opt").read(), "ltl2tgba.opt", 'exec'),
|
||||||
|
global_vars, local_vars)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -179,18 +208,18 @@ import spot
|
||||||
import buddy
|
import buddy
|
||||||
|
|
||||||
def alarm_handler(signum, frame):
|
def alarm_handler(signum, frame):
|
||||||
print """<p><font color="red">The script was aborted because
|
unbufprint("""<p><font color="red">The script was aborted because
|
||||||
it has been running for too long.</font> Please try a shorter formula,
|
it has been running for too long.</font> Please try a shorter formula,
|
||||||
or different options (not drawing automata usually helps).
|
or different options (not drawing automata usually helps).
|
||||||
If you want to benchmark big formulae it is
|
If you want to benchmark big formulae it is
|
||||||
better to install Spot on your own computer.</p>"""
|
better to install Spot on your own computer.</p>\n""")
|
||||||
finish(kill = True)
|
finish(kill = True)
|
||||||
|
|
||||||
def reset_alarm():
|
def reset_alarm():
|
||||||
signal.alarm(30)
|
signal.alarm(30)
|
||||||
|
|
||||||
def render_dot(basename):
|
def render_dot(basename):
|
||||||
print '<div class="dot">'
|
unbufprint('<div class="dot">')
|
||||||
if svg_output:
|
if svg_output:
|
||||||
ext = 'svg'
|
ext = 'svg'
|
||||||
else:
|
else:
|
||||||
|
|
@ -207,32 +236,32 @@ def render_dot(basename):
|
||||||
os.link(outname, tmpdir + "/" + ext)
|
os.link(outname, tmpdir + "/" + ext)
|
||||||
b = cgi.escape(basename)
|
b = cgi.escape(basename)
|
||||||
if svg_output:
|
if svg_output:
|
||||||
print ('<object type="image/svg+xml" data="' + b + '.svg">'
|
unbufprint('<object type="image/svg+xml" data="' + b +
|
||||||
+ 'Your browser does not support SVG.</object>')
|
'.svg">Your browser does not support SVG.</object>')
|
||||||
else:
|
else:
|
||||||
print ('<img src="' + b + '.png"><br>(<a href="' + b
|
unbufprint('<img src="' + b + '.png"><br>(<a href="' + b
|
||||||
+ '.txt">dot source</a>)')
|
+ '.txt">dot source</a>)')
|
||||||
print '</div>'
|
unbufprint('</div>\n')
|
||||||
|
|
||||||
def render_dot_maybe(dotsrc, dont_run_dot):
|
def render_dot_maybe(dotsrc, dont_run_dot):
|
||||||
# The dot output is named after the SHA1 of the dot source.
|
# The dot output is named after the SHA1 of the dot source.
|
||||||
# This way we can cache two different requests that generate
|
# This way we can cache two different requests that generate
|
||||||
# the same automaton (e.g., when changing a simplification
|
# the same automaton (e.g., when changing a simplification
|
||||||
# option that has no influence).
|
# option that has no influence).
|
||||||
autprefix = imgdir + '/' + hashlib.sha1(dotsrc).hexdigest()
|
autprefix = (imgdir + '/' + hashlib.sha1(dotsrc).hexdigest())
|
||||||
dotname = autprefix + '.txt'
|
dotname = autprefix + '.txt'
|
||||||
if not os.access(dotname, os.F_OK):
|
if not os.access(dotname, os.F_OK):
|
||||||
dotout = open(dotname, "w", 0)
|
dotout = open(dotname, "wb", 0)
|
||||||
dotout.write(dotsrc)
|
dotout.write(dotsrc)
|
||||||
dotout.close()
|
dotout.close()
|
||||||
# Create an unused hardlink that points to the output picture
|
# Create a unused hardlink that points to the output picture
|
||||||
# just to remember how many cache entries are sharing it.
|
# just to remember how many cache entries are sharing it.
|
||||||
os.link(dotname, tmpdir + "/txt")
|
os.link(dotname, tmpdir + "/txt")
|
||||||
|
|
||||||
if dont_run_dot:
|
if dont_run_dot:
|
||||||
print ('<p>' + dont_run_dot + ''' to be rendered on-line. However
|
unbufprint('<p>' + dont_run_dot + ''' to be rendered on-line.
|
||||||
you may download the <a href="''' + cgi.escape(autprefix)
|
However you may download the <a href="''' + cgi.escape(autprefix)
|
||||||
+ '.txt">source in dot format</a> and render it yourself.')
|
+ '.txt">source in dot format</a> and render it yourself.</p>\n')
|
||||||
else:
|
else:
|
||||||
render_dot(autprefix)
|
render_dot(autprefix)
|
||||||
|
|
||||||
|
|
@ -242,7 +271,7 @@ def render_automaton(automaton, dont_run_dot, issba, deco = False):
|
||||||
spot.dotty_reachable(dotsrc, automaton, issba)
|
spot.dotty_reachable(dotsrc, automaton, issba)
|
||||||
else:
|
else:
|
||||||
spot.dotty_reachable(dotsrc, automaton, issba, deco)
|
spot.dotty_reachable(dotsrc, automaton, issba, deco)
|
||||||
render_dot_maybe(dotsrc.str(), dont_run_dot)
|
render_dot_maybe(dotsrc.str().encode('utf-8'), dont_run_dot)
|
||||||
|
|
||||||
def render_formula(f):
|
def render_formula(f):
|
||||||
dotsrc = spot.ostringstream()
|
dotsrc = spot.ostringstream()
|
||||||
|
|
@ -251,35 +280,28 @@ def render_formula(f):
|
||||||
|
|
||||||
def print_stats(automaton):
|
def print_stats(automaton):
|
||||||
stats = spot.stats_reachable(automaton)
|
stats = spot.stats_reachable(automaton)
|
||||||
print "<p>", stats.states,
|
unbufprint("<p>%d state" % stats.states)
|
||||||
if stats.states <= 1:
|
if stats.states > 1:
|
||||||
print " state,",
|
unbufprint("s")
|
||||||
else:
|
unbufprint(", %d transition" % stats.transitions)
|
||||||
print " states,",
|
if stats.transitions > 1:
|
||||||
print stats.transitions,
|
unbufprint("s")
|
||||||
if stats.transitions <= 1:
|
|
||||||
print " transition,",
|
|
||||||
else:
|
|
||||||
print " transitions,",
|
|
||||||
# compute the number of acceptance conditions
|
|
||||||
count = automaton.number_of_acceptance_conditions()
|
count = automaton.number_of_acceptance_conditions()
|
||||||
if count > 0:
|
if count > 0:
|
||||||
print count,
|
unbufprint(", %d acceptance condition" % count)
|
||||||
if count <= 1:
|
if count > 1:
|
||||||
print "acceptance condition:",
|
unbufprint("s")
|
||||||
else:
|
|
||||||
print "acceptance conditions:",
|
|
||||||
acc = automaton.all_acceptance_conditions()
|
acc = automaton.all_acceptance_conditions()
|
||||||
print spot.bdd_format_accset(automaton.get_dict(), acc)
|
unbufprint(": " + spot.bdd_format_accset(automaton.get_dict(), acc))
|
||||||
else:
|
else:
|
||||||
print "no acceptance condition (all cycles are accepting)"
|
unbufprint(", no acceptance condition (all cycles are accepting)")
|
||||||
print "</p>"
|
unbufprint("</p>\n")
|
||||||
# Decide whether we will render the automaton or not.
|
# Decide whether we will render the automaton or not.
|
||||||
# (A webserver is not a computation center...)
|
# (A webserver is not a computation center...)
|
||||||
if stats.states > 64:
|
if stats.states > 64:
|
||||||
return "Automaton has too much states"
|
return "Automaton has too much states"
|
||||||
if float(stats.transitions)/stats.states > 10:
|
if float(stats.transitions)/stats.states > 10:
|
||||||
return "Automaton has too much transitions per states"
|
return "Automaton has too much transitions per state"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
form = cgi.FieldStorage()
|
form = cgi.FieldStorage()
|
||||||
|
|
@ -288,7 +310,7 @@ output_type = form.getfirst('o', 'v');
|
||||||
|
|
||||||
# Version requested.
|
# Version requested.
|
||||||
if output_type == 'v':
|
if output_type == 'v':
|
||||||
print 'Spot version ' + spot.version()
|
unbufprint('Spot version %s\n' % spot.version())
|
||||||
finish()
|
finish()
|
||||||
|
|
||||||
spot.unblock_signal(signal.SIGALRM)
|
spot.unblock_signal(signal.SIGALRM)
|
||||||
|
|
@ -304,9 +326,13 @@ pel = spot.empty_parse_error_list()
|
||||||
f = spot.parse(formula, pel, env)
|
f = spot.parse(formula, pel, env)
|
||||||
|
|
||||||
if pel:
|
if pel:
|
||||||
print '<div class="parse-error">'
|
unbufprint('<div class="parse-error">')
|
||||||
err = spot.format_parse_errors(spot.get_cout(), formula, pel)
|
err = spot.format_parse_errors(spot.get_cout(), formula, pel)
|
||||||
print '</div>'
|
unbufprint('</div>')
|
||||||
|
|
||||||
|
# Do not continue if we could not parse anything sensible.
|
||||||
|
if not f:
|
||||||
|
finish()
|
||||||
|
|
||||||
# Formula simplifications
|
# Formula simplifications
|
||||||
opt = spot.Reduce_None
|
opt = spot.Reduce_None
|
||||||
|
|
@ -328,12 +354,11 @@ if opt != spot.Reduce_None:
|
||||||
if output_type == 'f':
|
if output_type == 'f':
|
||||||
formula_format = form.getfirst('ff', 'o')
|
formula_format = form.getfirst('ff', 'o')
|
||||||
# o = Spot, i = Spin, g = GraphViz
|
# o = Spot, i = Spin, g = GraphViz
|
||||||
|
|
||||||
if formula_format == 'o':
|
if formula_format == 'o':
|
||||||
print '<div class="formula spot-format">%s</div>' % f
|
unbufprint('<div class="formula spot-format">%s</div>' % f)
|
||||||
elif formula_format == 'i':
|
elif formula_format == 'i':
|
||||||
print ('<div class="formula spin-format">'
|
unbufprint('<div class="formula spin-format">'
|
||||||
+ spot.to_spin_string(f) + '</div>')
|
+ spot.to_spin_string(f) + '</div>')
|
||||||
elif formula_format == 'g':
|
elif formula_format == 'g':
|
||||||
render_formula(f)
|
render_formula(f)
|
||||||
finish()
|
finish()
|
||||||
|
|
@ -377,9 +402,9 @@ issba = False
|
||||||
if output_type == 'm':
|
if output_type == 'm':
|
||||||
automaton = spot.scc_filter(automaton)
|
automaton = spot.scc_filter(automaton)
|
||||||
automaton = spot.minimize_monitor(automaton)
|
automaton = spot.minimize_monitor(automaton)
|
||||||
print '<div class="automata-stats">'
|
unbufprint('<div class="automata-stats">')
|
||||||
dont_run_dot = print_stats(automaton)
|
dont_run_dot = print_stats(automaton)
|
||||||
print '</div>'
|
unbufprint('</div>')
|
||||||
render_automaton(automaton, dont_run_dot, issba)
|
render_automaton(automaton, dont_run_dot, issba)
|
||||||
automaton = 0
|
automaton = 0
|
||||||
finish()
|
finish()
|
||||||
|
|
@ -398,7 +423,7 @@ if output_type == 'a':
|
||||||
elif output_type == 'r':
|
elif output_type == 'r':
|
||||||
buchi_type = form.getfirst('ra', 't')
|
buchi_type = form.getfirst('ra', 't')
|
||||||
else:
|
else:
|
||||||
print "Unkown output type 'o=%s'." % output_type
|
unbufprint("Unkown output type 'o=%s'.\n" % output_type)
|
||||||
automaton = 0
|
automaton = 0
|
||||||
finish()
|
finish()
|
||||||
|
|
||||||
|
|
@ -435,7 +460,7 @@ if output_type == 'a':
|
||||||
if buchi_type == 'i':
|
if buchi_type == 'i':
|
||||||
s = spot.ostringstream()
|
s = spot.ostringstream()
|
||||||
spot.never_claim_reachable(s, degen, f)
|
spot.never_claim_reachable(s, degen, f)
|
||||||
print '<div class="neverclaim">%s</div>' % cgi.escape(s.str())
|
unbufprint('<div class="neverclaim">%s</div>' % cgi.escape(s.str()))
|
||||||
del s
|
del s
|
||||||
else: # 't' or 's'
|
else: # 't' or 's'
|
||||||
dont_run_dot = print_stats(degen)
|
dont_run_dot = print_stats(degen)
|
||||||
|
|
@ -462,20 +487,28 @@ if output_type == 'r':
|
||||||
eci, err = spot.emptiness_check_instantiator.construct(opt)
|
eci, err = spot.emptiness_check_instantiator.construct(opt)
|
||||||
|
|
||||||
if not eci:
|
if not eci:
|
||||||
print ('<div class="parse-error">Cannot parse "' + opt + '" near "'
|
unbufprint('<div class="parse-error">Cannot parse "' + opt
|
||||||
+ err + '".</div>')
|
+ '" near "' + err + '".</div>')
|
||||||
else:
|
else:
|
||||||
ec_a = 0
|
ec_a = 0
|
||||||
n_acc = degen.number_of_acceptance_conditions()
|
n_acc = degen.number_of_acceptance_conditions()
|
||||||
n_max = eci.max_acceptance_conditions()
|
n_max = eci.max_acceptance_conditions()
|
||||||
|
n_min = eci.min_acceptance_conditions()
|
||||||
if (n_acc <= n_max):
|
if (n_acc <= n_max):
|
||||||
ec_a = degen
|
if (n_acc >= n_min):
|
||||||
|
ec_a = degen
|
||||||
|
else:
|
||||||
|
unbufprint('<div class="ec-error">Cannot run ' + opt
|
||||||
|
+ ' on automata with less than ' + str(n_min)
|
||||||
|
+ ' acceptance condition.<br/>Please build '
|
||||||
|
+ 'a degeneralized Büchi automaton if you '
|
||||||
|
+ 'want to try this algorithm.</div>')
|
||||||
else:
|
else:
|
||||||
print ('<div class="ec-error">Cannot run ' + opt
|
unbufprint('<div class="ec-error">Cannot run ' + opt
|
||||||
+ ' on automata with more than ' + str(n_max)
|
+ ' on automata with more than ' + str(n_max)
|
||||||
+ ' acceptance condition.<br/>Please build '
|
+ ' acceptance condition.<br/>Please build '
|
||||||
+ 'a degeneralized Büchi automaton if you '
|
+ 'a degeneralized Büchi automaton if you '
|
||||||
+ 'want to try this algorithm.</div>')
|
+ 'want to try this algorithm.</div>')
|
||||||
if ec_a:
|
if ec_a:
|
||||||
ec = eci.instantiate(ec_a)
|
ec = eci.instantiate(ec_a)
|
||||||
else:
|
else:
|
||||||
|
|
@ -484,15 +517,16 @@ if output_type == 'r':
|
||||||
if ec:
|
if ec:
|
||||||
ec_res = ec.check()
|
ec_res = ec.check()
|
||||||
if not ec_res:
|
if not ec_res:
|
||||||
print '<div class="ec">No accepting run found.</div>'
|
unbufprint('<div class="ec">No accepting run found.</div>')
|
||||||
else:
|
else:
|
||||||
ec_run = ec_res.accepting_run()
|
ec_run = ec_res.accepting_run()
|
||||||
print '<div class="ec">An accepting run was found.<br/>'
|
unbufprint('<div class="ec">An accepting run was found.<br/>')
|
||||||
if ec_run:
|
if ec_run:
|
||||||
if print_acc_run:
|
if print_acc_run:
|
||||||
s = spot.ostringstream()
|
s = spot.ostringstream()
|
||||||
spot.print_tgba_run(s, ec_a, ec_run)
|
spot.print_tgba_run(s, ec_a, ec_run)
|
||||||
print '<div class="accrun">%s</div>' % cgi.escape(s.str())
|
unbufprint('<div class="accrun">%s</div>' %
|
||||||
|
cgi.escape(s.str()))
|
||||||
del s
|
del s
|
||||||
|
|
||||||
if draw_acc_run:
|
if draw_acc_run:
|
||||||
|
|
@ -502,7 +536,7 @@ if output_type == 'r':
|
||||||
del deco
|
del deco
|
||||||
del ec_run
|
del ec_run
|
||||||
del ec_res
|
del ec_res
|
||||||
print '</div>'
|
unbufprint('</div>')
|
||||||
del ec
|
del ec
|
||||||
del ec_a
|
del ec_a
|
||||||
degen = 0
|
degen = 0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright (C) 2010, 2011 Laboratoire de Recherche et Développement de l'EPITA.
|
// -*- coding: utf-8 -*-
|
||||||
|
// Copyright (C) 2010, 2011, 2012 Laboratoire de Recherche et
|
||||||
|
// Développement de l'EPITA.
|
||||||
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
// et Marie Curie.
|
// et Marie Curie.
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
|
|
@ -224,11 +226,17 @@ extern const bdd bddtrue;
|
||||||
#define BDD_REORDER_RANDOM 7
|
#define BDD_REORDER_RANDOM 7
|
||||||
|
|
||||||
%extend bdd {
|
%extend bdd {
|
||||||
int
|
// For Python 2.0
|
||||||
__cmp__(bdd* b)
|
int __cmp__(bdd* b) { return b->id() - self->id(); }
|
||||||
{
|
|
||||||
return b->id() - self->id();
|
// For Python 2.1+ and Python 3
|
||||||
}
|
bool __le__(bdd* b) { return self->id() <= b->id(); }
|
||||||
|
bool __lt__(bdd* b) { return self->id() < b->id(); }
|
||||||
|
bool __eq__(bdd* b) { return self->id() == b->id(); }
|
||||||
|
bool __ne__(bdd* b) { return self->id() != b->id(); }
|
||||||
|
bool __ge__(bdd* b) { return self->id() >= b->id(); }
|
||||||
|
bool __gt__(bdd* b) { return self->id() > b->id(); }
|
||||||
|
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
__str__(void)
|
__str__(void)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
|
// -*- encoding: utf-8 -*-
|
||||||
// Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Développement
|
// Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche
|
||||||
// de l'Epita (LRDE).
|
// et Développement de l'Epita (LRDE).
|
||||||
// Copyright (C) 2003, 2004, 2005, 2006 Laboratoire d'Informatique
|
// Copyright (C) 2003, 2004, 2005, 2006 Laboratoire d'Informatique
|
||||||
// de Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
// de Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
|
||||||
// Université Pierre et Marie Curie.
|
// Université Pierre et Marie Curie.
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
//
|
//
|
||||||
|
|
@ -114,6 +114,11 @@ using namespace spot;
|
||||||
"$result = t_output_helper($result, SWIG_FromCharPtr(*$1));";
|
"$result = t_output_helper($result, SWIG_FromCharPtr(*$1));";
|
||||||
%apply char** OUTPUT { char** err };
|
%apply char** OUTPUT { char** err };
|
||||||
|
|
||||||
|
// False and True cannot be redefined in Python3, even in a class.
|
||||||
|
// Spot uses these in an enum of the constant class.
|
||||||
|
%rename(FalseVal) False;
|
||||||
|
%rename(TrueVal) True;
|
||||||
|
|
||||||
%include "misc/version.hh"
|
%include "misc/version.hh"
|
||||||
%include "misc/bddalloc.hh"
|
%include "misc/bddalloc.hh"
|
||||||
%include "misc/minato.hh"
|
%include "misc/minato.hh"
|
||||||
|
|
@ -203,11 +208,23 @@ using namespace spot;
|
||||||
|
|
||||||
// When comparing formula, make sure Python compare our
|
// When comparing formula, make sure Python compare our
|
||||||
// pointers, not the pointers to its wrappers.
|
// pointers, not the pointers to its wrappers.
|
||||||
int
|
|
||||||
__cmp__(const spot::ltl::formula* b)
|
// __cmp__ is for Python 2.0
|
||||||
{
|
int __cmp__(const spot::ltl::formula* b) { return self - b; }
|
||||||
return b - self;
|
// These are for Python 2.1+ or 3.x. They more closely match
|
||||||
}
|
// the logic in Spot.
|
||||||
|
bool __lt__(const spot::ltl::formula* b)
|
||||||
|
{ spot::ltl::formula_ptr_less_than lt; return lt(self, b); }
|
||||||
|
bool __le__(const spot::ltl::formula* b)
|
||||||
|
{ spot::ltl::formula_ptr_less_than lt; return !lt(b, self); }
|
||||||
|
bool __eq__(const spot::ltl::formula* b) { return self == b; }
|
||||||
|
bool __ne__(const spot::ltl::formula* b) { return self != b; }
|
||||||
|
bool __gt__(const spot::ltl::formula* b)
|
||||||
|
{ spot::ltl::formula_ptr_less_than lt; return lt(b, self); }
|
||||||
|
bool __ge__(const spot::ltl::formula* b)
|
||||||
|
{ spot::ltl::formula_ptr_less_than lt; return !lt(self, b); }
|
||||||
|
|
||||||
|
size_t __hash__() { return self->hash(); }
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
__str__(void)
|
__str__(void)
|
||||||
|
|
@ -265,12 +282,24 @@ get_cout()
|
||||||
return std::cout;
|
return std::cout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nl_cout()
|
||||||
|
{
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
get_cerr()
|
get_cerr()
|
||||||
{
|
{
|
||||||
return std::cerr;
|
return std::cerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nl_cerr()
|
||||||
|
{
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
print_on(std::ostream& on, const std::string& what)
|
print_on(std::ostream& on, const std::string& what)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- mode: python; coding: utf-8 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2010, 2011 Laboratoire de Recherche et Développement
|
# Copyright (C) 2010, 2011, 2012 Laboratoire de Recherche et
|
||||||
# de l'EPITA.
|
# Développement de l'EPITA.
|
||||||
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6
|
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6
|
||||||
# (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
|
# (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
|
||||||
# Pierre et Marie Curie.
|
# Pierre et Marie Curie.
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from buddy import *
|
from buddy import *
|
||||||
|
from spot import nl_cout
|
||||||
|
|
||||||
# Build the requirements for all other fields than (i,j) assuming
|
# Build the requirements for all other fields than (i,j) assuming
|
||||||
# that (i,j) has a queen.
|
# that (i,j) has a queen.
|
||||||
|
|
@ -89,15 +90,15 @@ for i in side:
|
||||||
# Build requirements for each variable(field).
|
# Build requirements for each variable(field).
|
||||||
for i in side:
|
for i in side:
|
||||||
for j in side:
|
for j in side:
|
||||||
print "Adding position %d, %d" % (i, j)
|
sys.stdout.write("Adding position %d, %d\n" % (i, j))
|
||||||
build(i, j)
|
build(i, j)
|
||||||
|
|
||||||
# Print the results.
|
# Print the results.
|
||||||
print "There are", bdd_satcount(queen), "solutions"
|
sys.stdout.write("There are %d solutions, one is:\n" %
|
||||||
print "one is:"
|
bdd_satcount(queen))
|
||||||
solution = bdd_satone(queen)
|
solution = bdd_satone(queen)
|
||||||
bdd_printset(solution)
|
bdd_printset(solution)
|
||||||
print
|
nl_cout()
|
||||||
|
|
||||||
# Cleanup all BDD variables before calling bdd_done(), otherwise
|
# Cleanup all BDD variables before calling bdd_done(), otherwise
|
||||||
# bdd_delref will be called after bdd_done() and this is unsafe in
|
# bdd_delref will be called after bdd_done() and this is unsafe in
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
# -*- mode: python; coding: iso-8859-1 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2003, 2004, 2010 Laboratoire d'Informatique de Paris 6 (LIP6),
|
# Copyright (C) 2010, 2012 Laboratoire de Recherche et Développement
|
||||||
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
# de l'EPITA.
|
||||||
# et Marie Curie.
|
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6
|
||||||
|
# (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
|
||||||
|
# Pierre et Marie Curie.
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
#
|
#
|
||||||
|
|
@ -24,6 +26,7 @@
|
||||||
# are not problematic.
|
# are not problematic.
|
||||||
import buddy
|
import buddy
|
||||||
import spot
|
import spot
|
||||||
|
import sys
|
||||||
e = spot.default_environment.instance()
|
e = spot.default_environment.instance()
|
||||||
p = spot.empty_parse_error_list()
|
p = spot.empty_parse_error_list()
|
||||||
f = spot.parse('GFa', p, e)
|
f = spot.parse('GFa', p, e)
|
||||||
|
|
@ -31,13 +34,13 @@ dict = spot.bdd_dict()
|
||||||
a = spot.ltl_to_tgba_lacim(f, dict)
|
a = spot.ltl_to_tgba_lacim(f, dict)
|
||||||
s0 = a.get_init_state()
|
s0 = a.get_init_state()
|
||||||
b = s0.as_bdd()
|
b = s0.as_bdd()
|
||||||
print b
|
sys.stdout.write("%s\n" % b)
|
||||||
iter = a.succ_iter(s0)
|
iter = a.succ_iter(s0)
|
||||||
iter.first()
|
iter.first()
|
||||||
while not iter.done():
|
while not iter.done():
|
||||||
c = iter.current_condition()
|
c = iter.current_condition()
|
||||||
print c
|
sys.stdout.write("%s\n" % c)
|
||||||
b &= c # `&=' is defined only in buddy. So if this statement works
|
b &= c # `&=' is defined only in buddy. So if this statement works
|
||||||
# it means buddy can grok spot's objects.
|
# it means buddy can grok spot's objects.
|
||||||
iter.next()
|
iter.next()
|
||||||
print b
|
sys.stdout.write("%s\n" % b)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- mode: python; coding: iso-8859-1 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
# Copyright (C) 2009, 2010, 2012 Laboratoire de Recherche et
|
||||||
# de l'Epita (LRDE).
|
# Développement de l'Epita (LRDE).
|
||||||
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
# et Marie Curie.
|
# et Marie Curie.
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -30,7 +30,7 @@ import getopt
|
||||||
import spot
|
import spot
|
||||||
|
|
||||||
def usage(prog):
|
def usage(prog):
|
||||||
print "Usage: ", prog, """ [OPTIONS...] formula
|
sys.stderr.write("""Usage: %s [OPTIONS...] formula
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-a display the acceptance_conditions BDD, not the reachability graph
|
-a display the acceptance_conditions BDD, not the reachability graph
|
||||||
|
|
@ -41,7 +41,8 @@ Options:
|
||||||
-r display the relation BDD, not the reachability graph
|
-r display the relation BDD, not the reachability graph
|
||||||
-R same as -r, but as a set
|
-R same as -r, but as a set
|
||||||
-t display reachable states in LBTT's format
|
-t display reachable states in LBTT's format
|
||||||
-v display the BDD variables used by the automaton"""
|
-v display the BDD variables used by the automaton
|
||||||
|
""" % prog)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -122,12 +123,12 @@ if f:
|
||||||
if concrete:
|
if concrete:
|
||||||
spot.bdd_print_set(cout, concrete.get_dict(),
|
spot.bdd_print_set(cout, concrete.get_dict(),
|
||||||
concrete.get_core_data().relation)
|
concrete.get_core_data().relation)
|
||||||
print
|
spot.nl_cout()
|
||||||
elif output == 4:
|
elif output == 4:
|
||||||
if concrete:
|
if concrete:
|
||||||
spot.bdd_print_set(cout, concrete.get_dict(),
|
spot.bdd_print_set(cout, concrete.get_dict(),
|
||||||
concrete.get_core_data().acceptance_conditions)
|
concrete.get_core_data().acceptance_conditions)
|
||||||
print
|
spot.nl_cout()
|
||||||
elif output == 5:
|
elif output == 5:
|
||||||
a.get_dict().dump(cout)
|
a.get_dict().dump(cout)
|
||||||
elif output == 6:
|
elif output == 6:
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- mode: python; coding: iso-8859-1 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
# Copyright (C) 2009, 2010, 2012 Laboratoire de Recherche et Développement
|
||||||
# de l'Epita (LRDE).
|
# de l'Epita (LRDE).
|
||||||
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
# et Marie Curie.
|
# et Marie Curie.
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -36,12 +36,12 @@ for str1 in l:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
str2 = str(f)
|
str2 = str(f)
|
||||||
f.destroy()
|
f.destroy()
|
||||||
print str2
|
sys.stdout.write(str2 + "\n")
|
||||||
# Try to reparse the stringified formula
|
# Try to reparse the stringified formula
|
||||||
f = spot.parse(str2, p, e)
|
f = spot.parse(str2, p, e)
|
||||||
if spot.format_parse_errors(spot.get_cout(), str2, p):
|
if spot.format_parse_errors(spot.get_cout(), str2, p):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
print f
|
sys.stdout.write(str(f) + "\n")
|
||||||
f.destroy()
|
f.destroy()
|
||||||
|
|
||||||
assert spot.atomic_prop.instance_count() == 0
|
assert spot.atomic_prop.instance_count() == 0
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- mode: python; coding: iso-8859-1 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
# Copyright (C) 2009, 2010, 2012 Laboratoire de Recherche et Développement
|
||||||
# de l'Epita (LRDE).
|
# de l'Epita (LRDE).
|
||||||
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
# et Marie Curie.
|
# et Marie Curie.
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
# 02111-1307, USA.
|
# 02111-1307, USA.
|
||||||
|
|
||||||
import spot
|
import spot
|
||||||
|
import sys
|
||||||
|
|
||||||
e = spot.default_environment.instance()
|
e = spot.default_environment.instance()
|
||||||
|
|
||||||
|
|
@ -42,18 +43,18 @@ op2 = spot.multop.instance(spot.multop.And, op, c)
|
||||||
# suppressed, so we don't attempt to reuse it elsewhere.
|
# suppressed, so we don't attempt to reuse it elsewhere.
|
||||||
del op, c
|
del op, c
|
||||||
|
|
||||||
print 'op2 =', op2
|
sys.stdout.write('op2 = %s\n' % str(op2))
|
||||||
|
|
||||||
op3 = spot.multop.instance(spot.multop.And, b,
|
op3 = spot.multop.instance(spot.multop.And, b,
|
||||||
spot.multop.instance(spot.multop.And, c2, a))
|
spot.multop.instance(spot.multop.And, c2, a))
|
||||||
del a, b, c2
|
del a, b, c2
|
||||||
|
|
||||||
print 'op3 =', op3
|
sys.stdout.write('op3 = %s\n' % str(op3))
|
||||||
assert op2 == op3
|
assert op2 == op3
|
||||||
|
|
||||||
op4 = spot.multop.instance(spot.multop.Or, op2, op3)
|
op4 = spot.multop.instance(spot.multop.Or, op2, op3)
|
||||||
|
|
||||||
print 'op4 =', op4
|
sys.stdout.write('op4 = %s\n' % str(op4))
|
||||||
assert op4 == op2
|
assert op4 == op2
|
||||||
|
|
||||||
del op2, op3
|
del op2, op3
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
# -*- mode: python; coding: iso-8859-1 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2004, 2010 Laboratoire d'Informatique de Paris 6 (LIP6),
|
# Copyright (C) 2010, 2012 Laboratoire de Recherche et Développement
|
||||||
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
# de l'Epita
|
||||||
|
# Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
|
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
# et Marie Curie.
|
# et Marie Curie.
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -40,7 +42,7 @@ i = isop.next()
|
||||||
l = []
|
l = []
|
||||||
while i != buddy.bddfalse:
|
while i != buddy.bddfalse:
|
||||||
buddy.bdd_printset(i)
|
buddy.bdd_printset(i)
|
||||||
print
|
spot.nl_cout()
|
||||||
l.append(i)
|
l.append(i)
|
||||||
i = isop.next()
|
i = isop.next()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
# -*- mode: python; coding: iso-8859-1 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2004, 2010 Laboratoire d'Informatique de Paris 6 (LIP6),
|
# Copyright (C) 2010, 2012 Laboratoire de Recherche et Développement
|
||||||
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
# de l'Epita.
|
||||||
|
# Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
|
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
# et Marie Curie.
|
# et Marie Curie.
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -21,6 +23,7 @@
|
||||||
# 02111-1307, USA.
|
# 02111-1307, USA.
|
||||||
|
|
||||||
import spot
|
import spot
|
||||||
|
import sys
|
||||||
|
|
||||||
class test(spot.loopless_modular_mixed_radix_gray_code):
|
class test(spot.loopless_modular_mixed_radix_gray_code):
|
||||||
def __init__(self, lim):
|
def __init__(self, lim):
|
||||||
|
|
@ -43,7 +46,7 @@ class test(spot.loopless_modular_mixed_radix_gray_code):
|
||||||
while not self.done():
|
while not self.done():
|
||||||
m = "".join(self.msg)
|
m = "".join(self.msg)
|
||||||
res.append(m)
|
res.append(m)
|
||||||
print m
|
sys.stdout.write(m + "\n")
|
||||||
self.next()
|
self.next()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
# -*- mode: python; coding: iso-8859-1 -*-
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
# Copyright (C) 2005, 2010 Laboratoire d'Informatique de Paris 6 (LIP6),
|
# Copyright (C) 2010, 2012 Laboratoire de Recherche et Développement
|
||||||
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
# de l'EPITA.
|
||||||
|
# Copyright (C) 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||||
|
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||||
# et Marie Curie.
|
# et Marie Curie.
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -47,17 +49,13 @@ assert o.get('optB') == 0
|
||||||
assert o.get('optC') == 1
|
assert o.get('optC') == 1
|
||||||
|
|
||||||
res = o.parse_options("!")
|
res = o.parse_options("!")
|
||||||
print res
|
|
||||||
assert res == "!"
|
assert res == "!"
|
||||||
|
|
||||||
res = o.parse_options("foo, !opt = 1")
|
res = o.parse_options("foo, !opt = 1")
|
||||||
print res
|
|
||||||
assert res == "!opt = 1"
|
assert res == "!opt = 1"
|
||||||
|
|
||||||
res = o.parse_options("foo=3, opt == 1")
|
res = o.parse_options("foo=3, opt == 1")
|
||||||
print res
|
|
||||||
assert res == "opt == 1"
|
assert res == "opt == 1"
|
||||||
|
|
||||||
res = o.parse_options("foo=3opt == 1")
|
res = o.parse_options("foo=3opt == 1")
|
||||||
print res
|
|
||||||
assert res == "3opt == 1"
|
assert res == "3opt == 1"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue