Browse Source

Update gen_rust.py help

Joeri Exelmans 4 years ago
parent
commit
efbbb31c9e
1 changed files with 18 additions and 19 deletions
  1. 18 19
      src/sccd/statechart/cmd/gen_rust.py

+ 18 - 19
src/sccd/statechart/cmd/gen_rust.py

@@ -1,31 +1,30 @@
 import argparse
 import sys
-import termcolor
-from functools import partial
-from sccd.statechart.parser.xml import *
-from sccd.test.parser.xml import *
-
-from sccd.statechart.codegen.rust import compile_statechart
-from sccd.test.codegen.rust import compile_test
-
-from sccd.util.indenting_writer import *
-
-# Note: Rust code is written to stdout and should be compiled to a library
-
-# Test syntax correctness as follows:
-
-#    python -m sccd.statechart.cmd.gen_rust <path/to/statechart.xml> | tee >(cat 1>&2) | rustc --crate-type=lib -
+import os
 
+# Output can be piped to Rust compiler as follows:
+#
+# For statecharts (build library):
+#  python -m sccd.statechart.cmd.gen_rust <path/to/statechart.xml> | rustc --crate-type=lib -
+#
+# For tests (build executable):
+#  python -m sccd.statechart.cmd.gen_rust <path/to/test.xml> | rustc -
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(
-        description="Generate Rust code.")
-    parser.add_argument('path', metavar='PATH', type=str, help="Model to check.")
+        description="Generate Rust code. Rust code is written to stdout.")
+    parser.add_argument('path', metavar='PATH', type=str, help="A SCCD statechart or test XML file. A statechart can be compiled to a Rust library. A test can be compiled to a Rust executable (the main-function runs the test).")
     args = parser.parse_args()
-
     src = args.path
-
     path = os.path.dirname(src)
+
+    from sccd.statechart.parser.xml import *
+    from sccd.test.parser.xml import *
+    from sccd.statechart.codegen.rust import compile_statechart
+    from sccd.test.codegen.rust import compile_test
+    from sccd.util.indenting_writer import *
+    from functools import partial
+
     globals = Globals()
 
     sc_parser_rules = partial(statechart_parser_rules, path=path, load_external=True)