Add example of 'woods' operational semantics. Clearer error messages. Implement full OD-API. Small refactoring of Conformance class.
This commit is contained in:
parent
f2dc299eab
commit
cd26a401fe
7 changed files with 449 additions and 63 deletions
|
|
@ -14,4 +14,26 @@ def yes_no(msg: str):
|
|||
|
||||
def pause():
|
||||
print("press any key...")
|
||||
input()
|
||||
input()
|
||||
|
||||
def choose(msg:str, options):
|
||||
arr = []
|
||||
for i, (key, result) in enumerate(options):
|
||||
print(f" {i}. {key}")
|
||||
arr.append(result)
|
||||
if len(arr) == 0:
|
||||
return
|
||||
return __choose(msg, arr)
|
||||
|
||||
def __choose(msg: str, arr):
|
||||
sys.stdout.write(f"{msg} ")
|
||||
try:
|
||||
raw = input()
|
||||
choice = int(raw) # may raise ValueError
|
||||
if choice >= 0 and choice < len(arr):
|
||||
return arr[choice]
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
print("Invalid option")
|
||||
return __choose(msg, arr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue