diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-17 20:58:58 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2018-05-17 20:58:58 +0200 |
| commit | de5d76118fe96a41785a6f62ea1da4172753a5b9 (patch) | |
| tree | 36f445a663a5f80e3b2dd58240608f3aabdc215a /kconfiglib.py | |
| parent | eed407ea559224529823a4616cff1a30a939af00 (diff) | |
Factor out symbol type setting
Get rid of some code duplication.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index de6b79b..411e693 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -2132,14 +2132,7 @@ class Kconfig(object): continue if t0 in _TYPE_TOKENS: - new_type = _TOKEN_TO_TYPE[t0] - - if node.item.orig_type not in (UNKNOWN, new_type): - self._warn("{} defined with multiple types, {} will be used" - .format(_name_and_loc(node.item), - TYPE_TO_STR[new_type])) - - node.item.orig_type = new_type + self._set_type(node, _TOKEN_TO_TYPE[t0]) if self._peek_token() is not None: if node.prompt: @@ -2228,15 +2221,7 @@ class Kconfig(object): self._parse_cond())) elif t0 in (_T_DEF_BOOL, _T_DEF_TRISTATE): - new_type = _TOKEN_TO_TYPE[t0] - - if node.item.orig_type not in (UNKNOWN, new_type): - self._warn("{} defined with multiple types, {} will be used" - .format(_name_and_loc(node.item), - TYPE_TO_STR[new_type])) - - node.item.orig_type = new_type - + self._set_type(node, _TOKEN_TO_TYPE[t0]) node.defaults.append((self._parse_expr(False), self._parse_cond())) @@ -2329,6 +2314,14 @@ class Kconfig(object): self._tokens_i = -1 return + def _set_type(self, node, new_type): + if node.item.orig_type not in (UNKNOWN, new_type): + self._warn("{} defined with multiple types, {} will be used" + .format(_name_and_loc(node.item), + TYPE_TO_STR[new_type])) + + node.item.orig_type = new_type + 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 |
