Re: [PATCH v2 05/28] docs: kdoc_re: add a C tokenizer

Jonathan Corbet
2026-03-17T17:04:34Z

Mauro Carvalho Chehab <mchehab+huawei@kernel.org> writes:

>> > tools/lib/python/kdoc/kdoc_re.py | 234 +++++++++++++++++++++++++++++++
>> > 1 file changed, 234 insertions(+)
>> >
>> > diff --git a/tools/lib/python/kdoc/kdoc_re.py b/tools/lib/python/kdoc/kdoc_re.py
>> > index 085b89a4547c..7bed4e9a8810 100644
>> > --- a/tools/lib/python/kdoc/kdoc_re.py
>> > +++ b/tools/lib/python/kdoc/kdoc_re.py
>> > @@ -141,6 +141,240 @@ class KernRe:
>> >
>> > return self.last_match.groups()
>> >
>> > +class TokType():
>> > +
>> > + @staticmethod
>> > + def __str__(val):
>> > + ""Return the name of an enum value""
>> > + return TokType._name_by_val.get(val, f"UNKNOWN({val})")
>>
>> What is this class supposed to do?
>
> This __str__() method ensures that, when printing a CToken object,
> the name will be displayed, instead of a number. This is really
> useful when debugging.

I was talking about the TokType class, though, not CToken. This class
doesn't appear to be used anywhere. Indeed, I notice now that when you
relocate CToken in patch 7, TokType is silently removed. So perhaps
it's better not to introduce it in the first place :)

jon