Skip to main content

A simple parse tree utility package, with animated evaluations and configurable tree displays

Project description

Animated Parse Tree

Author Ethan Tan
Date 11/12/2021
Language Python (py)

Description

This package is meant to provide a high-level API for programmers to visualise parse trees. The eventual goal is to animate the tokenization (extracting symbols from a string), lexing (formatting the tokens), parsing (building the parse tree) and evaluation (reducing the parse tree).

Setup

It is extremely easy to integrate this package in your existing projects.

In the command line, run:

pip install animated_parse_tree

Sample Usage

Then in your Python source file / Jupyter Notebook, insert:

from animated_parse_tree import ParseTree

# Instantiate Parse Tree Object
t = ParseTree()

# Read a Mathematical String Expression (separated by singular whitespace characters)
t.read('1 + 2 * 3')

# Retrieve the Result
print('<<< Equation >>>')
print(t.expression, '=', t.evaluate(), end='\n\n')

# Display the Parse Tree
print('<<< Parse Tree >>>')
print(str(t))

The output in the terminal will look something like this:

<<< Equation >>>
1 + 2 * 3 = 7.0

<<< Parse Tree >>>
   +
 ↙     ↘
1.0    *
     ↙   ↘
    2.0 3.0

Declaring Custom Operands/Operators

Refer to bundles.py

See Also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

animated-parse-tree-0.0.8.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

animated_parse_tree-0.0.8-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file animated-parse-tree-0.0.8.tar.gz.

File metadata

  • Download URL: animated-parse-tree-0.0.8.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

File hashes

Hashes for animated-parse-tree-0.0.8.tar.gz
Algorithm Hash digest
SHA256 febe046a46e566c3e271de6e7e39d45d46b233c2023261df2163ce47ad472107
MD5 51880296bc4528b9e1c7eb3364374737
BLAKE2b-256 f0b5476aa03d009d1fdfe17d3a7ddd97ab06735ccf92f292ab8549d9fae8159c

See more details on using hashes here.

File details

Details for the file animated_parse_tree-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: animated_parse_tree-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

File hashes

Hashes for animated_parse_tree-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 352f514c32ae9ebc8084642ea90ad91a72896622aa234b9d3f56b8d5a43eb37a
MD5 9e465364b8a7ebc251e6f7c1b2084b13
BLAKE2b-256 e22e245603345b6022c9e6b2476eb16ee70e04bfc6b9e6317d94da7f7e3264da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page