OSDN Git Service

Hmm...
authorSimon Forman <sforman@hushmail.com>
Mon, 23 Nov 2020 16:59:20 +0000 (08:59 -0800)
committerSimon Forman <sforman@hushmail.com>
Mon, 23 Nov 2020 16:59:20 +0000 (08:59 -0800)
1  2 
joy/joy.py

diff --cc joy/joy.py
@@@ -31,36 -34,37 +31,43 @@@ from .utils.stack import stack_to_strin
  
  
  def joy(stack, expression, dictionary, viewer=None):
 -  '''Evaluate a Joy expression on a stack.
 +      '''Evaluate a Joy expression on a stack.
  
++<<<<<<< working copy
+   This function iterates through a sequence of terms which are either
+   literals (strings, numbers, sequences of terms) or function symbols.
+   Literals are put onto the stack and functions are looked up in the
+   dictionary and executed.
++=======
 +      This function iterates through a sequence of terms which are either
 +      literals (strings, numbers, sequences of terms) or function symbols.
 +      Literals are put onto the stack and functions are looked up in the
 +      disctionary and executed.
++>>>>>>> merge rev
  
 -  The viewer is a function that is called with the stack and expression
 -  on every iteration, its return value is ignored.
 +      The viewer is a function that is called with the stack and expression
 +      on every iteration, its return value is ignored.
  
 -  :param stack stack: The stack.
 -  :param stack expression: The expression to evaluate.
 -  :param dict dictionary: A ``dict`` mapping names to Joy functions.
 -  :param function viewer: Optional viewer function.
 -  :rtype: (stack, (), dictionary)
 +      :param stack stack: The stack.
 +      :param stack expression: The expression to evaluate.
 +      :param dict dictionary: A ``dict`` mapping names to Joy functions.
 +      :param function viewer: Optional viewer function.
 +      :rtype: (stack, (), dictionary)
  
 -  '''
 -  while expression:
 +      '''
 +      while expression:
  
 -    if viewer: viewer(stack, expression)
 +              if viewer: viewer(stack, expression)
  
 -    term, expression = expression
 -    if isinstance(term, Symbol):
 -      term = dictionary[term]
 -      stack, expression, dictionary = term(stack, expression, dictionary)
 -    else:
 -      stack = term, stack
 +              term, expression = expression
 +              if isinstance(term, Symbol):
 +                      term = dictionary[term]
 +                      stack, expression, dictionary = term(stack, expression, dictionary)
 +              else:
 +                      stack = term, stack
  
 -  if viewer: viewer(stack, expression)
 -  return stack, expression, dictionary
 +      if viewer: viewer(stack, expression)
 +      return stack, expression, dictionary
  
  
  def run(text, stack, dictionary, viewer=None):