summaryrefslogtreecommitdiffstats
path: root/util/cmake/pro2cmake.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/cmake/pro2cmake.py')
-rwxr-xr-xutil/cmake/pro2cmake.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/util/cmake/pro2cmake.py b/util/cmake/pro2cmake.py
index 3f9b4ccb53..ea68b57a19 100755
--- a/util/cmake/pro2cmake.py
+++ b/util/cmake/pro2cmake.py
@@ -683,6 +683,33 @@ class QmakeParser:
def __init__(self, *, debug: bool = False) -> None:
self._Grammar = self._generate_grammar(debug)
+ @staticmethod
+ def set_up_py_parsing_nicer_debug_output():
+ indent = -1
+
+ def increase_indent(fn):
+ def wrapper_function(*args):
+ nonlocal indent
+ indent += 1
+ print("> " * indent, end="")
+ return fn(*args)
+
+ return wrapper_function
+
+ def decrease_indent(fn):
+ def wrapper_function(*args):
+ nonlocal indent
+ print("> " * indent, end="")
+ indent -= 1
+ return fn(*args)
+
+ return wrapper_function
+
+ pp._defaultStartDebugAction = increase_indent(pp._defaultStartDebugAction)
+ pp._defaultSuccessDebugAction = decrease_indent(pp._defaultSuccessDebugAction)
+ pp._defaultExceptionDebugAction = decrease_indent(pp._defaultExceptionDebugAction)
+
+
def _generate_grammar(self, debug: bool):
# Define grammar:
pp.ParserElement.setDefaultWhitespaceChars(' \t')
@@ -829,6 +856,9 @@ class QmakeParser:
return result
+QmakeParser.set_up_py_parsing_nicer_debug_output()
+
+
def parseProFile(file: str, *, debug=False):
parser = QmakeParser(debug=debug)
return parser.parseFile(file)