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)
This commit is contained in:
James Vega 2004-08-28 22:28:44 +00:00
parent b6d28d7560
commit 6b59933673
2 changed files with 8 additions and 0 deletions

View File

@ -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):

View File

@ -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: