[PATCH v2 19/20] docs: c_lex: add support to work with pure name ids

From: Mauro Carvalho Chehab

Date: Thu Mar 12 2026 - 03:17:15 EST


Most of CMatch complexity is due to the need of parse macros
with arguments. Still, it is easy enough to support also simple
name identifiers.

Add support for it, as it simplifies xforms logic.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
---
tools/lib/python/kdoc/c_lex.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/lib/python/kdoc/c_lex.py b/tools/lib/python/kdoc/c_lex.py
index 98031cb7907c..689ad64ecbe4 100644
--- a/tools/lib/python/kdoc/c_lex.py
+++ b/tools/lib/python/kdoc/c_lex.py
@@ -477,9 +477,17 @@ class CMatch:

continue

- if not started and tok.kind == CToken.BEGIN:
- started = True
- continue
+ if not started:
+ if tok.kind == CToken.SPACE:
+ continue
+
+ if tok.kind == CToken.BEGIN:
+ started = True
+ continue
+ else:
+ # Name only token without BEGIN/END
+ yield start, i
+ start = None

if tok.kind == CToken.END and tok.level == stack[-1][1]:
start, level = stack.pop()
--
2.53.0