From 44b1172c9c010439c104fef429ba22137da0e133 Mon Sep 17 00:00:00 2001 From: MikePopoloski Date: Sat, 2 Dec 2023 12:06:27 -0500 Subject: [PATCH] Add driver example --- examples/driver.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/driver.py diff --git a/examples/driver.py b/examples/driver.py new file mode 100644 index 0000000..275194c --- /dev/null +++ b/examples/driver.py @@ -0,0 +1,26 @@ +import sys + +from pyslang import * + + +def main(): + # Create a slang driver with default command line arguments + driver = Driver() + driver.addStandardArgs() + + # Parse command line arguments + args = " ".join(sys.argv) + if not driver.parseCommandLine(args, CommandLineOptions()): + return + + # Process options and parse all provided sources + if not driver.processOptions() or not driver.parseAllSources(): + return + + # Perform elaboration and report all diagnostics + compilation = driver.createCompilation() + driver.reportCompilation(compilation, False) + + +if __name__ == "__main__": + main()