summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-05-17 21:07:40 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-05-17 21:07:56 +0200
commitdc6237f5906f5f1877c03698aae35fa6d1211a27 (patch)
tree6fb35e21bfeb80bdd69828589fd61174a7e57f0d
parentde5d76118fe96a41785a6f62ea1da4172753a5b9 (diff)
Factor out adding of prompts
Get rid of some code duplication.
-rw-r--r--kconfiglib.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 411e693..e669f72 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -2133,13 +2133,8 @@ class Kconfig(object):
if t0 in _TYPE_TOKENS:
self._set_type(node, _TOKEN_TO_TYPE[t0])
-
if self._peek_token() is not None:
- if node.prompt:
- self._warn("{} defined with multiple prompts in single location"
- .format(_name_and_loc(node.item)))
-
- node.prompt = (self._expect_str(), self._parse_cond())
+ self._parse_prompt(node)
elif t0 == _T_DEPENDS:
if not self._check_token(_T_ON):
@@ -2226,14 +2221,7 @@ class Kconfig(object):
self._parse_cond()))
elif t0 == _T_PROMPT:
- # 'prompt' properties override each other within a single
- # definition of a symbol, but additional prompts can be added
- # by defining the symbol multiple times
- if node.prompt:
- self._warn("{} defined with multiple prompts in single location"
- .format(_name_and_loc(node.item)))
-
- node.prompt = (self._expect_str(), self._parse_cond())
+ self._parse_prompt(node)
elif t0 == _T_RANGE:
node.ranges.append((self._expect_sym(),
@@ -2322,6 +2310,16 @@ class Kconfig(object):
node.item.orig_type = new_type
+ def _parse_prompt(self, node):
+ # 'prompt' properties override each other within a single definition of
+ # a symbol, but additional prompts can be added by defining the symbol
+ # multiple times
+ if node.prompt:
+ self._warn("{} defined with multiple prompts in single location"
+ .format(_name_and_loc(node.item)))
+
+ node.prompt = (self._expect_str(), self._parse_cond())
+
def _parse_expr(self, transform_m):
# Parses an expression from the tokens in Kconfig._tokens using a
# simple top-down approach. See the module docstring for the expression