Parsing Text into Joy Expressions

TODO: example…

joy.parser

This module exports a single function for converting text to a joy expression as well as a single Symbol class and a single Exception type.

The Symbol string class is used by the interpreter to recognize literals by the fact that they are not Symbol objects.

A crude grammar:

joy = term*
term = int | float | string | '[' joy ']' | function

A Joy expression is a sequence of zero or more terms

exception joy.parser.ParseError[source]

Raised when there is a error while parsing text.

class joy.parser.Symbol[source]

A string class that represents Joy function names.

joy.parser.text_to_expression(text)[source]

Convert a string to a Joy expression.

When supplied with a string this function returns a Python datastructure that represents the Joy datastructure described by the text expression. Any unbalanced square brackets will raise a ParseError.

Parameters:text (str) – Text to convert.
Return type:stack
Raises:ParseError – if the parse fails.

Parser Internals

TODO: Document things like the regular expressions used for tokenizing, and the re.Scanner, etc…