Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kdoc: replace NestedMatch with CMatch

Our previous approach to solve nested structs were to use
NestedMatch. It works well, but adding support to parse delimiters
is very complex.

Instead, use CMatch, which uses a C tokenizer, making the code more
reliable and simpler.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <900bff66f8093402999f9fe055fbfa3fa33a8d8b.1773770483.git.mchehab+huawei@kernel.org>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
600079fd c22aa12c

+17 -16
+1 -1
tools/lib/python/kdoc/kdoc_parser.py
··· 14 14 from pprint import pformat 15 15 16 16 from kdoc.c_lex import CTokenizer 17 - from kdoc.kdoc_re import NestedMatch, KernRe 17 + from kdoc.kdoc_re import KernRe 18 18 from kdoc.kdoc_item import KdocItem 19 19 20 20 #
+16 -15
tools/lib/python/kdoc/xforms_lists.py
··· 4 4 5 5 import re 6 6 7 - from kdoc.kdoc_re import KernRe, NestedMatch 7 + from kdoc.kdoc_re import KernRe 8 + from kdoc.c_lex import CMatch 8 9 9 10 struct_args_pattern = r'([^,)]+)' 10 11 ··· 61 60 # 62 61 # As it doesn't properly match the end parenthesis on some cases. 63 62 # 64 - # So, a better solution was crafted: there's now a NestedMatch 63 + # So, a better solution was crafted: there's now a CMatch 65 64 # class that ensures that delimiters after a search are properly 66 65 # matched. So, the implementation to drop STRUCT_GROUP() will be 67 66 # handled in separate. ··· 73 72 # 74 73 # Replace macros 75 74 # 76 - # TODO: use NestedMatch for FOO($1, $2, ...) matches 75 + # TODO: use CMatch for FOO($1, $2, ...) matches 77 76 # 78 - # it is better to also move those to the NestedMatch logic, 77 + # it is better to also move those to the CMatch logic, 79 78 # to ensure that parentheses will be properly matched. 80 79 # 81 80 (KernRe(r'__ETHTOOL_DECLARE_LINK_MODE_MASK\s*\(([^\)]+)\)', re.S), ··· 96 95 (KernRe(r'DEFINE_DMA_UNMAP_LEN\s*\(' + struct_args_pattern + r'\)', re.S), r'__u32 \1'), 97 96 (KernRe(r'VIRTIO_DECLARE_FEATURES\(([\w_]+)\)'), r'union { u64 \1; u64 \1_array[VIRTIO_FEATURES_U64S]; }'), 98 97 99 - (NestedMatch(r"__cond_acquires\s*\("), ""), 100 - (NestedMatch(r"__cond_releases\s*\("), ""), 101 - (NestedMatch(r"__acquires\s*\("), ""), 102 - (NestedMatch(r"__releases\s*\("), ""), 103 - (NestedMatch(r"__must_hold\s*\("), ""), 104 - (NestedMatch(r"__must_not_hold\s*\("), ""), 105 - (NestedMatch(r"__must_hold_shared\s*\("), ""), 106 - (NestedMatch(r"__cond_acquires_shared\s*\("), ""), 107 - (NestedMatch(r"__acquires_shared\s*\("), ""), 108 - (NestedMatch(r"__releases_shared\s*\("), ""), 109 - (NestedMatch(r'\bSTRUCT_GROUP\('), r'\0'), 98 + (CMatch(r"__cond_acquires"), ""), 99 + (CMatch(r"__cond_releases"), ""), 100 + (CMatch(r"__acquires"), ""), 101 + (CMatch(r"__releases"), ""), 102 + (CMatch(r"__must_hold"), ""), 103 + (CMatch(r"__must_not_hold"), ""), 104 + (CMatch(r"__must_hold_shared"), ""), 105 + (CMatch(r"__cond_acquires_shared"), ""), 106 + (CMatch(r"__acquires_shared"), ""), 107 + (CMatch(r"__releases_shared"), ""), 108 + (CMatch(r"STRUCT_GROUP"), r'\0'), 110 109 ] 111 110 112 111 #: Transforms for function prototypes.