From 8e2be80f43a2bdc4f4b84bb1ebd022df1bc65673 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Thu, 17 Jun 2021 13:12:52 +0200 Subject: Added a simple frontend for testing. --- pyGHDL/cli/DOM.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 pyGHDL/cli/DOM.py (limited to 'pyGHDL/cli/DOM.py') diff --git a/pyGHDL/cli/DOM.py b/pyGHDL/cli/DOM.py new file mode 100644 index 000000000..b8e6a134e --- /dev/null +++ b/pyGHDL/cli/DOM.py @@ -0,0 +1,48 @@ +from pathlib import Path + +from pydecor import export + +from pyGHDL.dom import Misc +from pyGHDL import GHDLBaseException + +__all__ = [] +__api__ = __all__ + +from pyGHDL.dom.formatting.prettyprint import PrettyPrint + + +@export +class Application: + _design: Misc.Design + + def __init__(self): + self._design = Misc.Design() + + def addFile(self, filename: Path, library: str): + document = Misc.Document(filename) + self._design.Documents.append(document) + + def prettyPrint(self): + buffer = [] + + PP = PrettyPrint() + + for doc in self._design.Documents: + for line in PP.formatDocument(doc): + buffer.append(line) + + print("\n".join(buffer)) + + +def main(): + try: + app = Application() + app.addFile(Path("testsuite/pyunit/SimpleEntity.vhdl"), "default_lib") + except GHDLBaseException as ex: + print(ex) + + app.prettyPrint() + + +if __name__ == "__main__": + main() -- cgit v1.2.3