Permalink
Browse files

Fix up array literal error.

Addresses issue #27 and #103.
  • Loading branch information...
Andy Chu
Andy Chu committed Aug 21, 2018
1 parent 23906a3 commit 7298396473fe803bcc7f8a4b24120e9083577020
Showing with 7 additions and 9 deletions.
  1. +4 −9 osh/word_parse.py
  2. +3 −0 test/parse-errors.sh
View
@@ -923,9 +923,8 @@ def ReadForExpression(self):
def _ReadArrayLiteralPart(self):
self._Next(lex_mode_e.OUTER) # advance past (
self._Peek()
if self.cur_token.id != Id.Op_LParen:
self.AddErrorContext('Expected ( after =', token=self.cur_token)
return None
# Checked by caller
assert self.cur_token.id == Id.Op_LParen, self.cur_token
# MUST use a new word parser (with same lexer).
w_parser = WordParser(self.lexer, self.line_reader)
@@ -944,9 +943,8 @@ def _ReadArrayLiteralPart(self):
elif word_id == Id.Op_Newline:
continue
else:
self.AddErrorContext(
'Unexpected word in array literal: %s', w, word=w)
return None
# TokenWord
p_die('Unexpected token in array literal: %r', w.token.val, word=w)
words.append(w)
@@ -1077,9 +1075,6 @@ def _ReadArithWord(self):
# Just return EOF token
w = ast.TokenWord(self.cur_token)
return w, False
#self.AddErrorContext("Unexpected EOF in arith context: %s",
# self.cur_token, token=self.cur_token)
#return None, False
elif self.token_kind == Kind.Ignored:
# Space should be ignored. TODO: change this to SPACE_SPACE and
View
@@ -79,6 +79,9 @@ word-parse() {
_error-case 'for (( i = 0; i < 10; i++ /'
_error-case 'echo @(extglob|foo'
# Array literal with invalid TokenWord.
_error-case 'a=(1 & 2)'
}
quoted-strings() {

0 comments on commit 7298396

Please sign in to comment.