From: Simon Forman Date: Tue, 16 Aug 2022 22:26:07 +0000 (-0700) Subject: Rebuild HTML docs. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4a5716d8b2c1a6aac7c9bf6a9a5b2a79b577d885;p=joypy%2FThun.git Rebuild HTML docs. --- diff --git a/docs/sphinx_docs/_build/doctrees/environment.pickle b/docs/sphinx_docs/_build/doctrees/environment.pickle index 5bd9019..1f9dd0d 100644 Binary files a/docs/sphinx_docs/_build/doctrees/environment.pickle and b/docs/sphinx_docs/_build/doctrees/environment.pickle differ diff --git a/docs/sphinx_docs/_build/doctrees/joy.doctree b/docs/sphinx_docs/_build/doctrees/joy.doctree index 506022d..a3e0fc8 100644 Binary files a/docs/sphinx_docs/_build/doctrees/joy.doctree and b/docs/sphinx_docs/_build/doctrees/joy.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/lib.doctree b/docs/sphinx_docs/_build/doctrees/lib.doctree index e433f50..66ed7a5 100644 Binary files a/docs/sphinx_docs/_build/doctrees/lib.doctree and b/docs/sphinx_docs/_build/doctrees/lib.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/library.doctree b/docs/sphinx_docs/_build/doctrees/library.doctree index 1236576..49aebd8 100644 Binary files a/docs/sphinx_docs/_build/doctrees/library.doctree and b/docs/sphinx_docs/_build/doctrees/library.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/notebooks/The_Four_Operations.doctree b/docs/sphinx_docs/_build/doctrees/notebooks/The_Four_Operations.doctree index 44265e5..d232c6e 100644 Binary files a/docs/sphinx_docs/_build/doctrees/notebooks/The_Four_Operations.doctree and b/docs/sphinx_docs/_build/doctrees/notebooks/The_Four_Operations.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/parser.doctree b/docs/sphinx_docs/_build/doctrees/parser.doctree index 40a38c2..7db8efb 100644 Binary files a/docs/sphinx_docs/_build/doctrees/parser.doctree and b/docs/sphinx_docs/_build/doctrees/parser.doctree differ diff --git a/docs/sphinx_docs/_build/doctrees/stack.doctree b/docs/sphinx_docs/_build/doctrees/stack.doctree index 6ce8d34..77c61da 100644 Binary files a/docs/sphinx_docs/_build/doctrees/stack.doctree and b/docs/sphinx_docs/_build/doctrees/stack.doctree differ diff --git a/docs/sphinx_docs/_build/html/_modules/joy/joy.html b/docs/sphinx_docs/_build/html/_modules/joy/joy.html index d240039..f84d742 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/joy.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/joy.html @@ -58,9 +58,9 @@ ''' from builtins import input from traceback import print_exc -from .parser import text_to_expression, ParseError, Symbol -from .utils.stack import stack_to_string -from .utils.errors import ( +from joy.parser import text_to_expression, ParseError, Symbol +from joy.utils.stack import stack_to_string +from joy.utils.errors import ( NotAListError, NotAnIntError, StackUnderflowError, @@ -71,12 +71,13 @@
[docs]def joy(stack, expression, dictionary, viewer=None): - '''Evaluate a Joy expression on a stack. + ''' + Evaluate a Joy expression on a stack. - 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 + dictionary and executed. The viewer is a function that is called with the stack and expression on every iteration, its return value is ignored. @@ -173,7 +174,7 @@ except NotAnIntError: print('Not an integer.') except NotAListError as e: - print(e) # 'Not a list.' + print(e) except: print_exc() print(stack_to_string(stack)) @@ -247,7 +248,7 @@
Thun Documentation by Simon Forman is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at https://osdn.net/projects/joypy/. - Created using Sphinx 4.3.0. + Created using Sphinx 4.4.0.
diff --git a/docs/sphinx_docs/_build/html/_modules/joy/library.html b/docs/sphinx_docs/_build/html/_modules/joy/library.html index da257c6..0b98def 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/library.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/library.html @@ -174,9 +174,9 @@ return inner -
[docs]def BinaryBuiltinWrapper(f): +
[docs]def BinaryMathWrapper(f): ''' - Wrap functions that take two arguments and return a single result. + Wrap functions that take two numbers and return a single result. ''' @FunctionWrapper @wraps(f) @@ -185,13 +185,33 @@ (a, (b, stack)) = stack except ValueError: raise StackUnderflowError('Not enough values on stack.') - # Boolean predicates like "or" fail here. :( -## if ( not isinstance(a, int) -## or not isinstance(b, int) -## or isinstance(a, bool) # Because bools are ints in Python. -## or isinstance(b, bool) + if ( not isinstance(a, int) + or not isinstance(b, int) + # bool is int in Python. + or isinstance(a, bool) + or isinstance(b, bool) + ): + raise NotAnIntError + result = f(b, a) + return (result, stack), expression, dictionary + return inner
+ + +
[docs]def BinaryLogicWrapper(f): + ''' + Wrap functions that take two numbers and return a single result. + ''' + @FunctionWrapper + @wraps(f) + def inner(stack, expression, dictionary): + try: + (a, (b, stack)) = stack + except ValueError: + raise StackUnderflowError('Not enough values on stack.') +## if (not isinstance(a, bool) +## or not isinstance(b, bool) ## ): -## raise NotAnIntError +## raise NotABoolError result = f(b, a) return (result, stack), expression, dictionary return inner
@@ -1364,27 +1384,27 @@ #divmod_ = pm = __(n2, n1), __(n4, n3) - BinaryBuiltinWrapper(operator.eq), - BinaryBuiltinWrapper(operator.ge), - BinaryBuiltinWrapper(operator.gt), - BinaryBuiltinWrapper(operator.le), - BinaryBuiltinWrapper(operator.lt), - BinaryBuiltinWrapper(operator.ne), - - BinaryBuiltinWrapper(operator.xor), - BinaryBuiltinWrapper(operator.lshift), - BinaryBuiltinWrapper(operator.rshift), - - BinaryBuiltinWrapper(operator.and_), - BinaryBuiltinWrapper(operator.or_), - - BinaryBuiltinWrapper(operator.add), - BinaryBuiltinWrapper(operator.floordiv), - BinaryBuiltinWrapper(operator.mod), - BinaryBuiltinWrapper(operator.mul), - BinaryBuiltinWrapper(operator.pow), - BinaryBuiltinWrapper(operator.sub), -## BinaryBuiltinWrapper(operator.truediv), + BinaryMathWrapper(operator.eq), + BinaryMathWrapper(operator.ge), + BinaryMathWrapper(operator.gt), + BinaryMathWrapper(operator.le), + BinaryMathWrapper(operator.lt), + BinaryMathWrapper(operator.ne), + + BinaryMathWrapper(operator.xor), + BinaryMathWrapper(operator.lshift), + BinaryMathWrapper(operator.rshift), + + BinaryLogicWrapper(operator.and_), + BinaryLogicWrapper(operator.or_), + + BinaryMathWrapper(operator.add), + BinaryMathWrapper(operator.floordiv), + BinaryMathWrapper(operator.mod), + BinaryMathWrapper(operator.mul), + BinaryMathWrapper(operator.pow), + BinaryMathWrapper(operator.sub), +## BinaryMathWrapper(operator.truediv), UnaryBuiltinWrapper(bool), UnaryBuiltinWrapper(operator.not_), diff --git a/docs/sphinx_docs/_build/html/_modules/joy/parser.html b/docs/sphinx_docs/_build/html/_modules/joy/parser.html index 153d3de..13e63f1 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/parser.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/parser.html @@ -60,18 +60,18 @@ A crude grammar:: joy = term* - term = int | float | string | '[' joy ']' | symbol + term = integer | '[' joy ']' | symbol A Joy expression is a sequence of zero or more terms. A term is a -literal value (integer, float, string, or Joy expression) or a function -symbol. Function symbols are unquoted strings and cannot contain square +literal value (integer or 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. ''' from re import Scanner -from .utils.stack import list_to_stack -from .utils.snippets import ( +from joy.utils.stack import list_to_stack +from joy.utils.snippets import ( pat as SNIPPETS, from_string, Snippet, diff --git a/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html b/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html index b9fa764..d0cba1d 100644 --- a/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html +++ b/docs/sphinx_docs/_build/html/_modules/joy/utils/stack.html @@ -56,6 +56,18 @@ permits certain operations such as iterating and pushing and popping values from (at least) one end. + In describing Joy I have used the term quotation to describe all of the + above, because I needed a word to describe the arguments to combinators + which fulfill the same role in Joy as lambda abstractions (with + variables) fulfill in the more familiar functional languages. I use the + term list for those quotations whose members are what I call literals: + numbers, characters, truth values, sets, strings and other quotations. + All these I call literals because their occurrence in code results in + them being pushed onto the stack. But I also call [London Paris] a list. + So, [dup \*] is a quotation but not a list. + +`"A Conversation with Manfred von Thun" w/ Stevan Apter <http://archive.vector.org.uk/art10000350>`_ + There is no "Stack" Python class, instead we use the `cons list`_, a venerable two-tuple recursive sequence datastructure, where the empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the @@ -95,7 +107,7 @@ We have two very simple functions, one to build up a stack from a Python -iterable and another to iterate through a stack and yield its items +list and another to iterate through a stack and yield its items one-by-one in order. There are also two functions to generate string representations of stacks. They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left. In both functions *internal stacks* are printed left-to-right. These functions are written to support :doc:`../pretty`. @@ -114,7 +126,9 @@ :param list el: A Python list or other sequence (iterators and generators won't work because ``reverse()`` is called on ``el``.) - :param stack stack: A stack, optional, defaults to the empty stack. + :param stack stack: A stack, optional, defaults to the empty stack. This + allows for concatinating Python lists (or other sequence objects) + onto an existing Joy stack. :rtype: stack ''' @@ -196,12 +210,12 @@ :param stack quote: A stack. :param stack expression: A stack. - :raises RuntimeError: if quote is larger than sys.getrecursionlimit(). :rtype: stack ''' # This is the fastest implementation, but will trigger # RuntimeError: maximum recursion depth exceeded # on quotes longer than sys.getrecursionlimit(). + # :raises RuntimeError: if quote is larger than sys.getrecursionlimit(). ## return (quote[0], concat(quote[1], expression)) if quote else expression @@ -212,10 +226,10 @@ # In-lining is slightly faster (and won't break the # recursion limit on long quotes.) + if not isinstance(quote, tuple): + raise NotAListError('Not a list.') temp = [] while quote: - if not isinstance(quote, tuple): - raise NotAListError(repr(quote)) item, quote = quote temp.append(item) for item in reversed(temp): diff --git a/docs/sphinx_docs/_build/html/_sources/lib.rst.txt b/docs/sphinx_docs/_build/html/_sources/lib.rst.txt index 2b93e4f..e341820 100644 --- a/docs/sphinx_docs/_build/html/_sources/lib.rst.txt +++ b/docs/sphinx_docs/_build/html/_sources/lib.rst.txt @@ -473,7 +473,7 @@ List words "Swap stack" swap the list on the top of the stack for the stack, and put the old stack on top of the new one. Think of it as a context -switch. Niether of the lists/stacks change their order. +switch. Neither of the lists/stacks change their order. .. code:: python diff --git a/docs/sphinx_docs/_build/html/_sources/notebooks/The_Four_Operations.rst.txt b/docs/sphinx_docs/_build/html/_sources/notebooks/The_Four_Operations.rst.txt index b345b0e..2dc77d3 100644 --- a/docs/sphinx_docs/_build/html/_sources/notebooks/The_Four_Operations.rst.txt +++ b/docs/sphinx_docs/_build/html/_sources/notebooks/The_Four_Operations.rst.txt @@ -316,7 +316,7 @@ The other sub-programs would be cancelled. “Fulminators” ^^^^^^^^^^^^^ -Also known as “Futures” or “Promises” (by *everybody* else. “Fulinators” +Also known as “Futures” or “Promises” (by *everybody* else. “Fulminators” is what I was going to call them when I was thinking about implementing them in Thun.) diff --git a/docs/sphinx_docs/_build/html/genindex.html b/docs/sphinx_docs/_build/html/genindex.html index f1bedb1..267a315 100644 --- a/docs/sphinx_docs/_build/html/genindex.html +++ b/docs/sphinx_docs/_build/html/genindex.html @@ -79,9 +79,11 @@

We have two very simple functions, one to build up a stack from a Python -iterable and another to iterate through a stack and yield its items +list and another to iterate through a stack and yield its items one-by-one in order. There are also two functions to generate string representations of stacks. They only differ in that one prints the terms in stack from left-to-right while the other prints from right-to-left. In both functions internal stacks are printed left-to-right. These functions are written to support Tracing Joy Execution.

@@ -93,11 +105,8 @@ printed left-to-right. These functions are written to support Raises -

RuntimeError – if quote is larger than sys.getrecursionlimit().

-
-
Return type
-

stack

+
Return type
+

stack

@@ -158,7 +167,9 @@ rearranging of the stack from e.g. the StackListbox.

  • el (list) – A Python list or other sequence (iterators and generators won’t work because reverse() is called on el.)

  • -
  • stack (stack) – A stack, optional, defaults to the empty stack.

  • +
  • stack (stack) – A stack, optional, defaults to the empty stack. This +allows for concatinating Python lists (or other sequence objects) +onto an existing Joy stack.

Return type
diff --git a/implementations/Python/joy/utils/stack.py b/implementations/Python/joy/utils/stack.py index 48223eb..c722bf4 100644 --- a/implementations/Python/joy/utils/stack.py +++ b/implementations/Python/joy/utils/stack.py @@ -23,18 +23,17 @@ When talking about Joy we use the terms "stack", "quote", "sequence", permits certain operations such as iterating and pushing and popping values from (at least) one end. -> In describing Joy I have used the term quotation to describe all of the -above, because I needed a word to describe the arguments to combinators -which fulfill the same role in Joy as lambda abstractions (with -variables) fulfill in the more familiar functional languages. I use the -term list for those quotations whose members are what I call literals: -numbers, characters, truth values, sets, strings and other quotations. -All these I call literals because their occurrence in code results in -them being pushed onto the stack. But I also call [London Paris] a list. -So, [dup *] is a quotation but not a list. - -"A Conversation with Manfred von Thun" w/ Stevan Apter -http://archive.vector.org.uk/art10000350 + In describing Joy I have used the term quotation to describe all of the + above, because I needed a word to describe the arguments to combinators + which fulfill the same role in Joy as lambda abstractions (with + variables) fulfill in the more familiar functional languages. I use the + term list for those quotations whose members are what I call literals: + numbers, characters, truth values, sets, strings and other quotations. + All these I call literals because their occurrence in code results in + them being pushed onto the stack. But I also call [London Paris] a list. + So, [dup \*] is a quotation but not a list. + +`"A Conversation with Manfred von Thun" w/ Stevan Apter `_ There is no "Stack" Python class, instead we use the `cons list`_, a venerable two-tuple recursive sequence datastructure, where the