mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
bitbake: codeparser.py: support deeply nested tokens
For shell constructs like echo hello & wait $! the process_tokens() method ended up with a situation where "token" in the "name, value = token" assignment was a list of tuples and not the expected tuple, causing the assignment to fail. There were already two for loops (one in _parse_shell(), one in process_tokens()) which iterated over token lists. Apparently the actual nesting can also be deeper. Now there is just one such loop in process_token_list() which calls itself recursively when it detects that a list entry is another list. As a side effect (improvement?!) of the loop removal in _parse_shell(), the local function definitions in process_tokens() get executed less often. Fixes: [YOCTO #10668] (Bitbake rev: 887ea6d25cee5114365dfbf1130603599e13ee80) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
2e132efa2f
commit
7d5822bf4c
@@ -342,8 +342,7 @@ class ShellParser():
|
|||||||
except pyshlex.NeedMore:
|
except pyshlex.NeedMore:
|
||||||
raise sherrors.ShellSyntaxError("Unexpected EOF")
|
raise sherrors.ShellSyntaxError("Unexpected EOF")
|
||||||
|
|
||||||
for token in tokens:
|
self.process_tokens(tokens)
|
||||||
self.process_tokens(token)
|
|
||||||
|
|
||||||
def process_tokens(self, tokens):
|
def process_tokens(self, tokens):
|
||||||
"""Process a supplied portion of the syntax tree as returned by
|
"""Process a supplied portion of the syntax tree as returned by
|
||||||
@@ -389,18 +388,24 @@ class ShellParser():
|
|||||||
"case_clause": case_clause,
|
"case_clause": case_clause,
|
||||||
}
|
}
|
||||||
|
|
||||||
for token in tokens:
|
def process_token_list(tokens):
|
||||||
name, value = token
|
for token in tokens:
|
||||||
try:
|
if isinstance(token, list):
|
||||||
more_tokens, words = token_handlers[name](value)
|
process_token_list(token)
|
||||||
except KeyError:
|
continue
|
||||||
raise NotImplementedError("Unsupported token type " + name)
|
name, value = token
|
||||||
|
try:
|
||||||
|
more_tokens, words = token_handlers[name](value)
|
||||||
|
except KeyError:
|
||||||
|
raise NotImplementedError("Unsupported token type " + name)
|
||||||
|
|
||||||
if more_tokens:
|
if more_tokens:
|
||||||
self.process_tokens(more_tokens)
|
self.process_tokens(more_tokens)
|
||||||
|
|
||||||
if words:
|
if words:
|
||||||
self.process_words(words)
|
self.process_words(words)
|
||||||
|
|
||||||
|
process_token_list(tokens)
|
||||||
|
|
||||||
def process_words(self, words):
|
def process_words(self, words):
|
||||||
"""Process a set of 'words' in pyshyacc parlance, which includes
|
"""Process a set of 'words' in pyshyacc parlance, which includes
|
||||||
|
|||||||
Reference in New Issue
Block a user