]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
xdrgen: Improve parse error reporting
authorChuck Lever <chuck.lever@oracle.com>
Mon, 22 Dec 2025 14:44:59 +0000 (09:44 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 26 Jan 2026 15:10:58 +0000 (10:10 -0500)
commit9abb3549227e4fb70f0d8ba515bf7ddd249ad710
treee7824270654e61cba1ff112df072a7bc50500edb
parenteb1f3b55ac6202a013daf14ed508066947cdafa8
xdrgen: Improve parse error reporting

The current verbose Lark exception output makes it difficult to
quickly identify and fix syntax errors in XDR specifications. Users
must wade through hundreds of lines of cascading errors to find the
root cause.

Replace this with concise, compiler-style error messages showing
file, line, column, the unexpected token, and the source line with
a caret pointing to the error location.

Before:
  Unexpected token Token('__ANON_1', '+1') at line 14, column 35.
  Expected one of:
          * SEMICOLON
  Previous tokens: [Token('__ANON_0', 'LM_MAXSTRLEN')]
  [hundreds more cascading errors...]

After:
  file.x:14:35: parse error
  Unexpected number '+1'

      const LM_MAXNAMELEN = LM_MAXSTRLEN+1;
                                        ^

The error handler now raises XdrParseError on the first error,
preventing cascading messages that obscure the root cause.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
tools/net/sunrpc/xdrgen/subcmds/declarations.py
tools/net/sunrpc/xdrgen/subcmds/definitions.py
tools/net/sunrpc/xdrgen/subcmds/lint.py
tools/net/sunrpc/xdrgen/subcmds/source.py
tools/net/sunrpc/xdrgen/xdr_parse.py
tools/net/sunrpc/xdrgen/xdrgen