Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com> Tested-by: Peter Schneider <pschneider1968@googlemail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Salvatore Bonaccorso <carnil@debian.org> Tested-by: Brett A C Sheffield <bacs@librecast.net> Tested-by: Mark Brown <broonie@kernel.org> Tested-by: Luna Jernberg <droidbittin@gmail.com> Tested-by: Ronald Warsow <rwarsow@gmx.de> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Tested-by: Ron Economos <re@w6rz.net> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34 lines
825 B
Python
34 lines
825 B
Python
#!/usr/bin/env python3
|
|
# ex: set filetype=python:
|
|
|
|
"""Translate an XDR specification into executable code that
|
|
can be compiled for the Linux kernel."""
|
|
|
|
import logging
|
|
|
|
from argparse import Namespace
|
|
from lark import logger
|
|
from lark.exceptions import UnexpectedInput
|
|
|
|
from xdr_parse import xdr_parser
|
|
from xdr_ast import transform_parse_tree
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
|
def handle_parse_error(e: UnexpectedInput) -> bool:
|
|
"""Simple parse error reporting, no recovery attempted"""
|
|
print(e)
|
|
return True
|
|
|
|
|
|
def subcmd(args: Namespace) -> int:
|
|
"""Lexical and syntax check of an XDR specification"""
|
|
|
|
parser = xdr_parser()
|
|
with open(args.filename, encoding="utf-8") as f:
|
|
parse_tree = parser.parse(f.read(), on_error=handle_parse_error)
|
|
transform_parse_tree(parse_tree)
|
|
|
|
return 0
|