mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
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:
parent
b6d28d7560
commit
6b59933673
@ -244,6 +244,7 @@ class Tokenizer:
|
|||||||
|
|
||||||
def _insideBrackets(self, lexer):
|
def _insideBrackets(self, lexer):
|
||||||
ret = []
|
ret = []
|
||||||
|
firstToken = True
|
||||||
while True:
|
while True:
|
||||||
token = lexer.get_token()
|
token = lexer.get_token()
|
||||||
if not token:
|
if not token:
|
||||||
@ -255,9 +256,15 @@ class Tokenizer:
|
|||||||
elif token == self.right:
|
elif token == self.right:
|
||||||
return ret
|
return ret
|
||||||
elif token == self.left:
|
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))
|
ret.append(self._insideBrackets(lexer))
|
||||||
else:
|
else:
|
||||||
ret.append(self._handleToken(token))
|
ret.append(self._handleToken(token))
|
||||||
|
firstToken = False
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def tokenize(self, s):
|
def tokenize(self, s):
|
||||||
|
@ -94,6 +94,7 @@ class TokenizerTestCase(SupyTestCase):
|
|||||||
def testError(self):
|
def testError(self):
|
||||||
self.assertRaises(SyntaxError, tokenize, '[foo') #]
|
self.assertRaises(SyntaxError, tokenize, '[foo') #]
|
||||||
self.assertRaises(SyntaxError, tokenize, '"foo') #"
|
self.assertRaises(SyntaxError, tokenize, '"foo') #"
|
||||||
|
self.assertRaises(SyntaxError, tokenize, '[[foo]]')
|
||||||
|
|
||||||
def testPipe(self):
|
def testPipe(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user