From c91e17c3f0b5410328b2d51c70224804e8b133cc Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 27 Sep 2018 16:44:17 +0200 Subject: Give clearer errors for bad endchoice/endif/endmenu nesting An endchoice/endif/endmenu with no corresponding choice/if/menu generated a cryptic 'unrecognized construct' parse error. Improve the error message so that the problem is pointed out explicitly: kconfiglib.KconfigError: Kconfig:37: couldn't parse 'endmenu': no corresponding 'menu' Reported in https://github.com/ulfalizer/Kconfiglib/issues/56. --- kconfiglib.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'kconfiglib.py') diff --git a/kconfiglib.py b/kconfiglib.py index 69f9e20..29f384b 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2606,7 +2606,15 @@ class Kconfig(object): self.top_node.linenr = self._linenr else: - self._parse_error("unrecognized construct") + # A valid endchoice/endif/endmenu is caught by the 'end_token' + # check above + self._parse_error("no corresponding 'choice'" + if t0 is _T_ENDCHOICE else + "no corresponding 'if'" + if t0 is _T_ENDIF else + "no corresponding 'menu'" + if t0 is _T_ENDMENU else + "unrecognized construct") # End of file reached. Terminate the final node and return it. -- cgit v1.2.3