board_inspector: fix an opcode peek issue

When parsing a sequence of clauses, it is not necessary to peek an opcode
from the current stream unless that sequence starts with one. Peeking an
opcode is even an error when the actual clause is empty (e.g. as a
TermList).

This patch makes the SequenceFactory only peeking at the next opcode when
the grammar expects one.

Tracked-On: #6298
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao 2021-07-18 16:06:37 +08:00 committed by Xie, Nanlin
parent 60da7d6bfd
commit 631d628178

View File

@ -297,7 +297,6 @@ class SequenceFactory(Factory):
tree.complete_parsing()
return tree
opcode, opcode_width = stream.peek_opcode()
package_end = 0
# Under any case this function shall maintain the balance of stream scopes. The following flags indicate the
@ -310,8 +309,8 @@ class SequenceFactory(Factory):
pos = stream.current
try:
if isinstance(elem, int): # The leading opcode
opcode, _ = stream.get_opcode()
assert elem == opcode
stream.seek(opcode_width)
elif elem.endswith("*"):
elem = elem[:-1]
factory = globals()[elem]