OSDN Git Service

No point in a separate _parse() function.
authorSimon Forman <sforman@hushmail.com>
Sun, 11 Sep 2022 00:22:37 +0000 (17:22 -0700)
committerSimon Forman <sforman@hushmail.com>
Sun, 11 Sep 2022 00:22:37 +0000 (17:22 -0700)
implementations/Python/simplejoy.py

index 416d546..833a277 100755 (executable)
@@ -326,8 +326,6 @@ literal value (integer, Boolean, or quoted Joy expression) or a function symbol.
 Function symbols are sequences of non-blanks and cannot contain square
 brackets.   Terms must be separated by blanks, which can be omitted
 around square brackets.
-
-
 '''
 
 
@@ -360,16 +358,9 @@ def text_to_expression(text):
     :rtype: stack
     :raises ParseError: if the parse fails.
     '''
-    return _parse(text.replace('[', ' [ ').replace(']', ' ] ').split())
-
-
-def _parse(tokens):
-    '''
-    Return a stack/list expression of the tokens.
-    '''
     frame = []
     stack = []
-    for tok in tokens:
+    for tok in text.replace('[', ' [ ').replace(']', ' ] ').split():
         if tok == '[':
             stack.append(frame)
             frame = []