66from pathlib import Path
77from typing import TYPE_CHECKING
88
9- from pyk .kast .inner import KSort , Subst
10-
119from kmir .build import semantics
1210from kmir .convert_from_definition .v2parser import parse_json
1311
@@ -23,6 +21,7 @@ class KMirOpts: ...
2321class RunOpts (KMirOpts ):
2422 input_file : Path
2523 depth : int
24+ start_symbol : str
2625
2726
2827def _kmir_run (opts : RunOpts ) -> None :
@@ -35,10 +34,7 @@ def _kmir_run(opts: RunOpts) -> None:
3534
3635 kmir_kast , _ = parse_result
3736
38- subst = Subst ({'$PGM' : kmir_kast })
39- init_config = subst .apply (tools .definition .init_config (KSort ('GeneratedTopCell' )))
40- init_kore = tools .krun .kast_to_kore (init_config , KSort ('GeneratedTopCell' ))
41- result = tools .krun .run_pattern (init_kore , depth = opts .depth )
37+ result = tools .run_parsed (kmir_kast , opts .start_symbol , opts .depth )
4238
4339 print (tools .kprint .kore_to_pretty (result ))
4440
@@ -60,6 +56,9 @@ def _arg_parser() -> ArgumentParser:
6056 run_parser = command_parser .add_parser ('run' , help = 'run stable MIR programs' )
6157 run_parser .add_argument ('input_file' , metavar = 'FILE' , help = 'MIR program to run' )
6258 run_parser .add_argument ('--depth' , type = int , metavar = 'DEPTH' , help = 'Depth to execute' )
59+ run_parser .add_argument (
60+ '--start-symbol' , type = str , metavar = 'SYMBOL' , default = 'main' , help = 'Symbol name to begin execution from'
61+ )
6362
6463 return parser
6564
@@ -69,7 +68,7 @@ def _parse_args(args: Sequence[str]) -> KMirOpts:
6968
7069 match ns .command :
7170 case 'run' :
72- return RunOpts (input_file = Path (ns .input_file ).resolve (), depth = ns .depth )
71+ return RunOpts (input_file = Path (ns .input_file ).resolve (), depth = ns .depth , start_symbol = ns . start_symbol )
7372 case _:
7473 raise AssertionError ()
7574
0 commit comments