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.6.tar.gz (11.7 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.6-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: animated-parse-tree-0.0.6.tar.gz
  • Upload date:
  • Size: 11.7 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.6.tar.gz
Algorithm Hash digest
SHA256 f732a3d5690e9d56a68d06781c31a204c7e52ea082b2e2b692cc7f42cb3dd470
MD5 854cfe0d2e6d729ac59055f49ec2ab74
BLAKE2b-256 080cde579bceb705870513962430b8e5e7c871c1fe1653aa27b57373fd180adc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: animated_parse_tree-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 15.3 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3ab5d71a2e4fba0ea34538511b9a61d40db9f48c712754030bec48b14c6938a0
MD5 78e0162583f31024d9f2f3ec66111507
BLAKE2b-256 8e0f0d803c14267f7614a2d847f3863d95afdb3b6245abe7c5f4f04e46ea7c21

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