summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-09-27 16:44:17 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-09-27 17:04:15 +0200
commitc91e17c3f0b5410328b2d51c70224804e8b133cc (patch)
treee7eca43aae85a86828c4bb14147f3850e672b5fe /kconfiglib.py
parentfe65588a5c5de4dffffe62e51b05dc8531b93c3e (diff)
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.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py10
1 files changed, 9 insertions, 1 deletions
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.