Skip to main content

PlusCal AST and builder in Python

Project description

pluscal

PlusCal AST and builder in Python

What Is This?

PlusCal is an algorithm language that compiles into a TLA+ specification. This library defines Python types that form an abstract syntax tree (AST) of the PlusCal P-Syntax grammar as well as a builder API for fluently constructing algorithms. The implementation leans heavily on Python dataclasses and type-hinting; a type checker (e.g. mypy) can be used to validate the grammar.

It is anticipated that this library will be used both by humans and by programs to construct grammatically correct specifications and run them through the TLC model checker.

Usage

Install from pip:

pip install pluscal

Create an algorithm:

>>> from pluscal.api import Algorithm, Print, Variable

>>> algorithm = Algorithm(
    "hello_world",
).declare(
    Variable("s").in_set("Hello", "World!"),
).do(
    Print("s", label="A"),
)

>>> print(algorithm)
--algorithm hello_world
variable s \in {"Hello", "World!"};
begin
  A:
    print s;
end algorithm

Limitations

This library is not complete. Some known limitations include:

  1. The lower-level TLA+ grammar used by the Expr, Field, Label, Name, and Variable types are neither modeled nor validated fully. These types are essentially strings at this time.

  2. The validation logic does not express the full nuances of PlusCal, especially as it relates to label placement.

    See section 3.7 of the PlusCal manual.

  3. Some of the fainess operations are not yet yet implemented.

    See section 4.6 of the PlusCal manual.

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

pluscal-0.4.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

pluscal-0.4.2-py2.py3-none-any.whl (30.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pluscal-0.4.2.tar.gz.

File metadata

  • Download URL: pluscal-0.4.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for pluscal-0.4.2.tar.gz
Algorithm Hash digest
SHA256 abe07ded72b331ba06b8ac33a3f87e864766758ab1b176b463774e07ada8d6ea
MD5 e3ca983abf20c7fdc7439577f9c28e55
BLAKE2b-256 a3188b5ad29469f5ccbc4e540fc1d9cbeae0b718fc3791c916d8f7b98d4c254b

See more details on using hashes here.

File details

Details for the file pluscal-0.4.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pluscal-0.4.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for pluscal-0.4.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dc015083f8d1c9070abac394e2e2644689c60bf829c48b06b0d64e425eadceaf
MD5 2922bbe52249a9a81e819ef1c600660e
BLAKE2b-256 fec6da8abfef6943e085a6ec31b47f61b1515eb596846956a70d9473389fdf76

See more details on using hashes here.

Supported by

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