From e77fed207a41a77f88853a89a8408fbfa9a17ddd Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 27 Nov 2020 05:59:56 +0900 Subject: [PATCH 1/2] hwdb: enable diagnostic switches --- hwdb.d/parse_hwdb.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hwdb.d/parse_hwdb.py b/hwdb.d/parse_hwdb.py index ed07224b3c..52f881623c 100755 --- a/hwdb.d/parse_hwdb.py +++ b/hwdb.d/parse_hwdb.py @@ -33,7 +33,7 @@ try: OneOrMore, Combine, Or, Optional, Suppress, Group, nums, alphanums, printables, stringEnd, pythonStyleComment, - ParseBaseException) + ParseBaseException, __diag__) except ImportError: print('pyparsing is not available') sys.exit(77) @@ -50,6 +50,12 @@ except ImportError: # don't do caching on old python lru_cache = lambda: (lambda f: f) +__diag__.warn_multiple_tokens_in_named_alternation = True +__diag__.warn_ungrouped_named_tokens_in_collection = True +__diag__.warn_name_set_on_empty_Forward = True +__diag__.warn_on_multiple_string_args_to_oneof = True +__diag__.enable_debug_on_named_expressions = True + EOL = LineEnd().suppress() EMPTYLINE = LineEnd() COMMENTLINE = pythonStyleComment + EOL From 315a3c9ff42afe8326ea34af3b2e8c720acc6658 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 27 Nov 2020 06:00:11 +0900 Subject: [PATCH 2/2] hwdb: add missing Group() This fixes the following warning: ``` parse_hwdb.py:120: UserWarning: warn_ungrouped_named_tokens_in_collection: setting results name 'SETTINGS*' on And expression collides with 'HZ' on contained expression dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*') ``` Not sure about for the mount_matrix, but LGTM.com warns in that line, and, adding Group() does not change the parse result. --- hwdb.d/parse_hwdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hwdb.d/parse_hwdb.py b/hwdb.d/parse_hwdb.py index 52f881623c..d1ff4470de 100755 --- a/hwdb.d/parse_hwdb.py +++ b/hwdb.d/parse_hwdb.py @@ -117,9 +117,9 @@ def hwdb_grammar(): def property_grammar(): ParserElement.setDefaultWhitespaceChars(' ') - dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*') + dpi_setting = Group(Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*') mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL - mount_matrix = (mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') + mount_matrix = Group(mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') xkb_setting = Optional(Word(alphanums + '+-/@._')) props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))),