-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preprocess contracts for ULM #189
Conversation
f040425
to
5f6fd45
Compare
7cff1cc
to
4a259b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all makes sense and looks good.
I left one minor comment.
from __future__ import annotations | ||
|
||
import sys | ||
from pathlib import Path | ||
from typing import TYPE_CHECKING | ||
|
||
from pyk.kore.parser import App, KoreParser | ||
|
||
if TYPE_CHECKING: | ||
from pyk.kore.syntax import Pattern | ||
|
||
|
||
def descend(patt: Pattern, path: list[str]) -> Pattern: | ||
for s in path: | ||
if not isinstance(patt, App): | ||
raise ValueError(type(patt)) | ||
new_patt: Pattern | None = None | ||
for p in patt.args: | ||
if isinstance(p, App): | ||
print(p.symbol, s) | ||
if p.symbol == s: | ||
new_patt = p | ||
break | ||
if new_patt is None: | ||
raise ValueError(patt.symbol) | ||
patt = new_patt | ||
return patt | ||
|
||
|
||
def main(args: list[str]) -> None: | ||
if len(args) != 2: | ||
raise ValueError(args) | ||
input_kore = Path(args[0]).read_text() | ||
config = KoreParser(input_kore).pattern() | ||
config = descend( | ||
config, | ||
["Lbl'-LT-'ulm-full-preprocessed'-GT-'"], | ||
) | ||
Path(args[1]).write_text(config.text) | ||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv[1:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this file isn't needed on this branch anymore --- do you think it is worth keeping around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not, removed.
4a259b4
to
bb40e1e
Compare
This continues my attempt to merge the ulm-virgil changes into the main semantics. However, instead of fully dropping the ULM preprocessing semantics, I am attempting to use it "the proper way".