No point in a separate _parse() function.
This commit is contained in:
@@ -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
|
Function symbols are sequences of non-blanks and cannot contain square
|
||||||
brackets. Terms must be separated by blanks, which can be omitted
|
brackets. Terms must be separated by blanks, which can be omitted
|
||||||
around square brackets.
|
around square brackets.
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
@@ -360,16 +358,9 @@ def text_to_expression(text):
|
|||||||
:rtype: stack
|
:rtype: stack
|
||||||
:raises ParseError: if the parse fails.
|
:raises ParseError: if the parse fails.
|
||||||
'''
|
'''
|
||||||
return _parse(text.replace('[', ' [ ').replace(']', ' ] ').split())
|
|
||||||
|
|
||||||
|
|
||||||
def _parse(tokens):
|
|
||||||
'''
|
|
||||||
Return a stack/list expression of the tokens.
|
|
||||||
'''
|
|
||||||
frame = []
|
frame = []
|
||||||
stack = []
|
stack = []
|
||||||
for tok in tokens:
|
for tok in text.replace('[', ' [ ').replace(']', ' ] ').split():
|
||||||
if tok == '[':
|
if tok == '[':
|
||||||
stack.append(frame)
|
stack.append(frame)
|
||||||
frame = []
|
frame = []
|
||||||
|
|||||||
Reference in New Issue
Block a user