From 6b59933673d72ccd7e9d1c3a37d0e6ab3a154ded Mon Sep 17 00:00:00 2001 From: James Vega Date: Sat, 28 Aug 2004 22:28:44 +0000 Subject: [PATCH] Let's make sure nested commands don't immediately nest commands (aka using a nested command to determine what the outer nested command is going to call) --- src/callbacks.py | 7 +++++++ test/test_callbacks.py | 1 + 2 files changed, 8 insertions(+) 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: