Skip to main content

pseudocode-interpreter

CC BY-SA 2021 Alfred Taylor & Conqu3red

(AQA) Exam Compatible Psuedocode V1 ALPHA (A.E.C.P/E.C.P)

PLEASE EXPECT LIMITED FUNCTIONALITY.

Introduction:

This is an adaptation of the pseudocode used by the AQA GCSE testing body (found here) that has had its syntax tweaked for use in a compiler and had some additional functionality added. The language will be fully Turing complete. Pseudocode found in tests is compatible with AECP/ECP. It is procedurally based, and shares similarities with python (It is programmed on python, after all.) It is intended as a scripting language, that is separate from python, but has the same basic functionality, whilst maintaining some resemblance of simplicity. Considering it is entirely written in python, it is not for use in situations where speed is a priority.

Interpreters

Currently we only have a python based interpreter, altough we have a C++ based interpreter coming soon.

How it works

AECP/ECP code is analysed and then parsed into a python AST (Abstract Syntax Tree). This can then be executed by the python interpreter. This allows near seamless integration with python and almost identical speed and behaviour.

Usage

Command Line arguments

usage: python -m ecp [-h] [--debug] [--trace [TRACE [TRACE ...]]] [--tracecompact] [--pause] [--version] [inputfile]

ECP interpreter

positional arguments:
  inputfile

optional arguments:
  -h, --help            show this help message and exit
  --debug               show debug information like token list
  --trace [TRACE [TRACE ...]]
                        space seperated names of the variables to be traced
  --tracecompact        trace compactly
  --pause               pause on completion
  --version             show program's version number and exit

Installation

pip install py-ecp

Running

python -m ecp path/to/ecp/file.ecp

Embedding ecp code in python files

from ecp import ecp

ecp("""
SUBROUTINE TotalOut(a, b)
    c ← a + b
    WHILE a < c
        a ← a + 1
        b ← b - a
    ENDWHILE
    RETURN b
ENDSUBROUTINE
""", scope=globals())

print(TotalOut(3, 4))

Converting ECp to python source code

python -m ecp path/to/ecp/file.ecp --topython

or:

from ecp import to_py_source
text = """
SUBROUTINE DoSomething(a, b)
    RETURN a + b
ENDSUBROUTINE
"""

print(to_py_source(text))

MORE COMING SOON!

Metadata

Release files for py-ecp 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-ecp 1.5.0
File Size Uploaded
py-ecp-1.5.0.tar.gz 23.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-ecp 1.5.0
File Interpreter ABI Platform
py_ecp-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.1 kB

Release files / py-ecp-1.5.0.tar.gz

Download URL py-ecp-1.5.0.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c953ce7e08c7e1d54a6953dab08d0a4b9f0b1c7d527e67f4ad41c79018f254de
BLAKE2b-256 checksum
How to use checksums
629b091e6720d12f517912c2ce54432029e891efc1ac4e6aea434e0454e89c21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release files / py_ecp-1.5.0-py3-none-any.whl

Download URL py_ecp-1.5.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4aad1a6296df4387c02e3e06829c8350153611454d1a8a7a13ccca762e66da7
BLAKE2b-256 checksum
How to use checksums
c87a2c7be295949f386773e82c313556a393a08cbd88cc0bb14e8f60e1f82fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page