diff --git a/src/callbacks.py b/src/callbacks.py index 9bd22a355..5ec7dbb77 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -244,6 +244,7 @@ class Tokenizer: def _insideBrackets(self, lexer): ret = [] + firstToken = True while True: token = lexer.get_token() if not token: @@ -255,9 +256,15 @@ class Tokenizer: elif token == self.right: return ret elif token == self.left: + if firstToken: + s = 'The command called may not be the result ' \ + 'of a nested command.' + raise SyntaxError, 'The command called may not be the ' \ + 'result or a nested command.' ret.append(self._insideBrackets(lexer)) else: ret.append(self._handleToken(token)) + firstToken = False return ret def tokenize(self, s): diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 5e4872572..4bfdd1043 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -94,6 +94,7 @@ class TokenizerTestCase(SupyTestCase): def testError(self): self.assertRaises(SyntaxError, tokenize, '[foo') #] self.assertRaises(SyntaxError, tokenize, '"foo') #" + self.assertRaises(SyntaxError, tokenize, '[[foo]]') def testPipe(self): try: