aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/cli
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-26 13:48:09 +0200
committerGitHub <noreply@github.com>2021-06-26 13:48:09 +0200
commit111fe055b2f0f3a0225d2553cf739572d691a14d (patch)
tree50d3a874bb78107627a6509fd4054c7fdc96cd25 /pyGHDL/cli
parent15c6de72bc8dd316cb5262e1b5f373ca45b05f68 (diff)
downloadghdl-111fe055b2f0f3a0225d2553cf739572d691a14d.tar.gz
ghdl-111fe055b2f0f3a0225d2553cf739572d691a14d.tar.bz2
ghdl-111fe055b2f0f3a0225d2553cf739572d691a14d.zip
More DOM improvements (#1806)
* First try to handle names. * Reworked names. * Reworked range expressions. * Handle AttributeNames. * Added handling of file declaration and attribute declarations. * Improved error outputs. * Handle protected types. * Make black happy with ugly code. * Handle Null literal and File parameters. * File type and physical type. * Don't fail on reported syntax errors. Catch call errors into libghdl. * Improved Sanity checks for pyGHDL.dom. * Load sourcecode via Python and process in-memory. Fixed testcases. * Added package instantiations and packages with generics. * Added UseClause, AttributeSpecification and PhysicalTypes. * Improved pretty-printing. * Fixed AttributeName in subtype indication. * Get code position of IIR nodes. * Added DOMMixin into all derived classes. * Mark as not yet implemented. * Pinned pyVHDLModel version to v0.10.4. * Removed xfail in LSP test. Bumped requirement of pyVHDLModel to v0.10.4. Fixed some Codacy issues. (cherry picked from commit f64e7ed7c3d69cbf84cd60db8e9b085e90b846cb)
Diffstat (limited to 'pyGHDL/cli')
-rwxr-xr-xpyGHDL/cli/DOM.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/pyGHDL/cli/DOM.py b/pyGHDL/cli/DOM.py
index dceafc629..622a70d16 100755
--- a/pyGHDL/cli/DOM.py
+++ b/pyGHDL/cli/DOM.py
@@ -4,12 +4,13 @@ from sys import argv
from sys import exit as sysexit
from pathlib import Path
+from textwrap import dedent
from pydecor import export
from pyGHDL import GHDLBaseException
from pyGHDL.libghdl import LibGHDLException
-from pyGHDL.dom.Common import DOMException
+from pyGHDL.dom import DOMException
from pyGHDL.dom.NonStandard import Design, Document
from pyGHDL.dom.formatting.prettyprint import PrettyPrint, PrettyPrintException
@@ -41,6 +42,19 @@ class Application:
print("\n".join(buffer))
+ document: Document = self._design.Documents[0]
+ print()
+ print(
+ "libghdl processing time: {: 5.3f} us".format(
+ document.LibGHDLProcessingTime * 10 ** 6
+ )
+ )
+ print(
+ "DOM translation time: {:5.3f} us".format(
+ document.DOMTranslationTime * 10 ** 6
+ )
+ )
+
def handleException(ex):
if isinstance(ex, PrettyPrintException):
@@ -52,6 +66,7 @@ def handleException(ex):
if ex2 is not None:
for message in ex2.InternalErrors:
print("libghdl: {message}".format(message=message))
+ return 0
return 4
elif isinstance(ex, LibGHDLException):
print("LIB:", ex)
@@ -81,8 +96,23 @@ def main(items=argv[1:]):
app = Application()
app.addFile(Path(item), "default_lib")
app.prettyPrint()
- except Exception as ex:
+ except GHDLBaseException as ex:
_exitcode = handleException(ex)
+ except Exception as ex:
+ print(
+ dedent(
+ """\
+ Fatal: An unhandled exception has reached to the top-most exception handler.
+ Exception: {name}
+ """.format(
+ name=ex.__class__.__name__
+ )
+ )
+ )
+ if isinstance(ex, ValueError):
+ print(" Message: {msg}".format(msg=str(ex)))
+ if ex.__cause__ is not None:
+ print("Cause: {msg}".format(msg=str(ex.__cause__)))
return _exitcode