Permalink
Browse files
Error location for unterminated double quoted string.
We attribute it to the beginning double quote.
From hg-other/eigen/bench/perf_monitoring/gemm/run.sh.txt
- Loading branch information...
Showing
with
11 additions
and
3 deletions.
-
+3
−1
core/ui.py
-
+1
−0
core/util.py
-
+4
−0
osh/cmd_parse_test.py
-
+3
−2
osh/word_parse.py
|
|
@@ -91,7 +91,9 @@ def MakeStatusLines(): |
|
|
|
|
|
def PrettyPrintError(parse_error, arena, f):
|
|
|
#print(parse_error)
|
|
|
if parse_error.token:
|
|
|
if parse_error.span_id:
|
|
|
span_id = parse_error.span_id
|
|
|
elif parse_error.token:
|
|
|
span_id = parse_error.token.span_id
|
|
|
elif parse_error.part:
|
|
|
span_id = word.LeftMostSpanForPart(parse_error.part)
|
|
|
|
|
|
@@ -37,6 +37,7 @@ def __init__(self, msg, *args, **kwargs): |
|
|
self.args = args
|
|
|
# NOTE: We use a kwargs dict because Python 2 doesn't have keyword-only
|
|
|
# args.
|
|
|
self.span_id = kwargs.pop('span_id', None)
|
|
|
self.token = kwargs.pop('token', None)
|
|
|
self.part = kwargs.pop('part', None)
|
|
|
self.word = kwargs.pop('word', None)
|
|
|
|
|
|
@@ -1258,6 +1258,10 @@ def testRedirectsInAssignment(self): |
|
|
err = _assertParseCommandListError(self, 'x=1 >/dev/null')
|
|
|
err = _assertParseCommandListError(self, 'declare x=1 >/dev/null')
|
|
|
|
|
|
def testEofInDoubleQuoted(self):
|
|
|
"""Enumerating errors in arith_parse.py."""
|
|
|
err = _assertParseCommandListError(self, 'foo="" echo "bar ')
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
unittest.main()
|
|
|
@@ -112,7 +112,6 @@ def Reset(self, lex_mode=LexMode.OUTER): |
|
|
|
|
|
self.error_stack = []
|
|
|
|
|
|
# TODO: Factor this into ErrorState class. Each parser owns one.
|
|
|
def AddErrorContext(self, msg, *args, **kwargs):
|
|
|
err = util.ParseError(msg, *args, **kwargs)
|
|
|
self.error_stack.append(err)
|
|
|
@@ -619,7 +618,9 @@ 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:
|
|
|
self.AddErrorContext('Unexpected EOF in double-quoted string')
|
|
|
self.AddErrorContext(
|
|
|
'Unexpected EOF reading double-quoted string that began here',
|
|
|
span_id=left_spid)
|
|
|
return False
|
|
|
|
|
|
else:
|
|
|
|
0 comments on commit
0bb6633