Created
June 9, 2022 07:06
-
-
Save CCXXXI/acc5d579d108aefb053ede5cae55aeee to your computer and use it in GitHub Desktop.
Used with http://www.lsv.fr/~gastin/ltl2ba/index.php .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def convert(s: str) -> str: | |
start = re.search(r"/\* (.*) \*/\s*", s).group(1).replace("( ", "(") | |
s = re.search(r"T0_init.*;", s, re.S).group(0) | |
s = re.sub(r"/\*.*\*/\s*", "", s) | |
s = s.replace("init", "S1").replace("&&", "&").replace("(", "").replace(")", "") | |
s = re.sub(r"\s*(if|fi;)", "", s) | |
s = re.sub(r"T\d+_S(\d+)", r"\1", s) | |
s = re.sub(r":\s+::", "= ?\n =", s) | |
s = s.replace("::", "|").replace("\t", " " * 4).replace(" -> goto accept_all", "") | |
s = re.sub(r"-> goto (\d+)", r"& X(\1)", s) | |
s += "\n\ntrue = true & X(true) " | |
s = s.replace("1 = ?", "1 = " + start) | |
return s | |
if __name__ == "__main__": | |
with open("in.txt") as f: | |
print() | |
print(convert(f.read())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment