added Node typevar
This commit is contained in:
parent
ba56886a4d
commit
c0b1dfd5ec
2 changed files with 14 additions and 8 deletions
|
|
@ -15,7 +15,10 @@
|
|||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
||||
sodipodi:docname="logo_text.svg">
|
||||
sodipodi:docname="logo_text.svg"
|
||||
inkscape:export-filename="/home/mvc/work/research/py-stl/assets/logo.png"
|
||||
inkscape:export-xdpi="99.997803"
|
||||
inkscape:export-ydpi="99.997803">
|
||||
<defs
|
||||
id="defs2">
|
||||
<marker
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.8 KiB |
17
mtl/ast.py
17
mtl/ast.py
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from collections import deque
|
||||
from typing import Union, NamedTuple
|
||||
from typing import Union, NamedTuple, TypeVar
|
||||
|
||||
import attr
|
||||
import funcy as fn
|
||||
|
|
@ -9,6 +9,9 @@ from lenses import bind
|
|||
from mtl import sugar
|
||||
|
||||
|
||||
Node = TypeVar("Node")
|
||||
|
||||
|
||||
def flatten_binary(phi, op, dropT, shortT):
|
||||
def f(x):
|
||||
return x.args if isinstance(x, op) else [x]
|
||||
|
|
@ -173,7 +176,7 @@ class Interval(NamedTuple):
|
|||
@ast_class
|
||||
class NaryOpMTL:
|
||||
OP = "?"
|
||||
args: "Node" # TODO: when 3.7 is more common replace with type union.
|
||||
args: Node # TODO: when 3.7 is more common replace with type union.
|
||||
|
||||
def __repr__(self):
|
||||
return "(" + f" {self.OP} ".join(f"{x}" for x in self.args) + ")"
|
||||
|
|
@ -191,7 +194,7 @@ class And(NaryOpMTL):
|
|||
class ModalOp:
|
||||
OP = '?'
|
||||
interval: Interval
|
||||
arg: "Node"
|
||||
arg: Node
|
||||
|
||||
def __repr__(self):
|
||||
if self.interval.lower == 0 and self.interval.upper == float('inf'):
|
||||
|
|
@ -209,8 +212,8 @@ class G(ModalOp):
|
|||
|
||||
@ast_class
|
||||
class WeakUntil:
|
||||
arg1: "Node"
|
||||
arg2: "Node"
|
||||
arg1: Node
|
||||
arg2: Node
|
||||
|
||||
def __repr__(self):
|
||||
return f"({self.arg1} W {self.arg2})"
|
||||
|
|
@ -222,7 +225,7 @@ class WeakUntil:
|
|||
|
||||
@ast_class
|
||||
class Neg:
|
||||
arg: "Node"
|
||||
arg: Node
|
||||
|
||||
def __repr__(self):
|
||||
return f"~{self.arg}"
|
||||
|
|
@ -234,7 +237,7 @@ class Neg:
|
|||
|
||||
@ast_class
|
||||
class Next:
|
||||
arg: "Node"
|
||||
arg: Node
|
||||
|
||||
def __repr__(self):
|
||||
return f"X{self.arg}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue