Skip to content

Commit

Permalink
Fix bug in previous commit: left_spid missing from DoubleQuotedPart.
Browse files Browse the repository at this point in the history
Also: Re-enable translation errors in wild_report.py.

Parse errors and translation errors seem to match 0.6.pre2 now.  TODO:
do another run.
  • Loading branch information
Andy Chu committed Aug 25, 2018
1 parent 7a1947f commit 2bba597
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
7 changes: 6 additions & 1 deletion osh/word_parse.py
Expand Up @@ -638,11 +638,15 @@ def _ReadDoubleQuotedPart(self, eof_type=Id.Undefined_Tok, here_doc=False):
Also ${foo%%a b c} # treat this as double quoted. until you hit
"""
quoted_part = ast.DoubleQuotedPart()
left_spid = const.NO_INTEGER

left_spid = const.NO_INTEGER # gets set later
right_spid = const.NO_INTEGER # gets set later

if self.cur_token is not None: # None in here doc case
left_token = self.cur_token
left_spid = left_token.span_id
else:
left_token = None

done = False
while not done:
Expand Down Expand Up @@ -684,6 +688,7 @@ def _ReadDoubleQuotedPart(self, eof_type=Id.Undefined_Tok, here_doc=False):
if here_doc: # here docs will have an EOF in their token stream
done = True
else:
assert left_token is not None # See hacky condition above
p_die('Unexpected EOF reading double-quoted string that began here',
token=left_token)

Expand Down
25 changes: 12 additions & 13 deletions test/wild_report.py
Expand Up @@ -233,11 +233,9 @@ def MakeHtmlGroup(title_str, body_str):
<td>
{.osh2oil_failed?}
<!-- <a class="fail" href="#stderr_osh2oil_{name}">FAIL</a> -->
FAIL
<a class="fail" href="#stderr_osh2oil_{name}">FAIL</a>
{.or}
<!-- <a class="ok" href="{name}__oil.txt">OK</a> -->
OK
<a class="ok" href="{name}__oil.txt">OK</a>
{.end}
</td>
<td class="name">
Expand Down Expand Up @@ -384,15 +382,16 @@ def UpdateNodes(node, path_parts, file_stats):
})
osh2oil_stderr = file_stats.pop('osh2oil_stderr')

# Concentrating on parsing failures for now.

#if osh2oil_stderr or file_stats['osh2oil_failed']:
# node.stderr.append({
# 'parsing': False,
# 'action': 'osh2oil',
# 'name': first,
# 'contents': osh2oil_stderr,
# })
# TODO: Could disable this with a flag to concentrate on parse errors.
# Or just show parse errors all in one file.
if 1:
if osh2oil_stderr or file_stats['osh2oil_failed']:
node.stderr.append({
'parsing': False,
'action': 'osh2oil',
'name': first,
'contents': osh2oil_stderr,
})

# Attach to this dir
node.files[first] = file_stats
Expand Down
3 changes: 2 additions & 1 deletion tools/osh2oil.py
Expand Up @@ -928,8 +928,9 @@ def DoWordInCommand(self, node, local_symbols):
node.parts[0].tag == word_part_e.DoubleQuotedPart):
dq_part = node.parts[0]

# TODO: Double quoted part needs left and right IDs
left_spid, right_spid = dq_part.spids
# This is not set in the case of here docs? Why not?
#assert left_spid != const.NO_INTEGER, left_spid
assert right_spid != const.NO_INTEGER, right_spid

if len(dq_part.parts) == 1:
Expand Down

0 comments on commit 2bba597

Please sign in to comment.