Permalink
Browse files

Attach span IDs to ExtGlobPart. Fixes a few crashes.

  • Loading branch information...
Andy Chu
Andy Chu committed Oct 19, 2017
1 parent 4e64a4d commit 23710581e3299d3edde634b25d7813d602a7626c
Showing with 13 additions and 3 deletions.
  1. +10 −1 core/word.py
  2. +3 −2 osh/word_parse.py
View
@@ -151,8 +151,14 @@ def LeftMostSpanForPart(part):
# begin, end
return part.spids[0]
elif part.tag == word_part_e.ExtGlobPart:
# This is the smae as part.op.span_id, but we want to be consistent with
# left/right. Not sure I want to add a right token just for the spid.
return part.spids[0]
#return part.op.span_id # e.g. @( is the left-most token
else:
raise AssertionError(part.tag)
raise AssertionError(part.__class__.__name__)
def _RightMostSpanForPart(part):
@@ -202,6 +208,9 @@ def _RightMostSpanForPart(part):
elif part.tag == word_part_e.ArithSubPart:
return -1
elif part.tag == word_part_e.ExtGlobPart:
return part.spids[1]
else:
raise AssertionError(part.tag)
View
@@ -574,7 +574,8 @@ def _ReadExtGlobPart(self):
"""
left_token = self.cur_token
arms = []
#log('left %r', left_token)
part = ast.ExtGlobPart(left_token, arms) # return value
part.spids.append(left_token.span_id)
self.lexer.PushHint(Id.Op_RParen, Id.Right_ExtGlob)
self._Next(LexMode.EXTGLOB) # advance past LEFT
@@ -588,6 +589,7 @@ def _ReadExtGlobPart(self):
if self.token_type == Id.Right_ExtGlob:
if not read_word:
arms.append(ast.CompoundWord())
part.spids.append(self.cur_token.span_id)
break
elif self.token_type == Id.Op_Pipe:
@@ -611,7 +613,6 @@ def _ReadExtGlobPart(self):
else:
raise AssertionError('Unexpected token %r' % self.cur_token)
part = ast.ExtGlobPart(left_token, arms)
return part
def _ReadDoubleQuotedPart(self, eof_type=Id.Undefined_Tok, here_doc=False):

0 comments on commit 2371058

Please sign in to comment.