Skip to main content

#+title: sxpyr: a flexible Lisp reader for Python

Parse s-expressions, edn, and a variety of lisp dialects.

  • Introduction Currently supports something approximating the union of Common Lisp, Scheme, Racket, Clojure, Hy, Fennel, and Emacs Lisp.

Since sxpyr is designed to support a variety of different dialects, a second pass is almost always needed in order to match the output of native readers. This second pass is a good place to raise additional syntax errors for the dialect you are working with. Some dialects have already been implemented.

Due to deeper differences between dialects, in some cases it is necessary to configure the reader in advance. This happens in cases where a particular form is valid in two different dialects and one or both parses are sufficiently divergent that it is not possible to recover the correct parse for the other dialect.

At the moment the reader cannot be modified at runtime. This means that it cannot be used to parse named readtables or things like Racket's #lang at-exp. In the future it might be possible to pass the generator through to the functions that handle dispatch macros and make it possible to register new reader macros, but that is well out of scope at the moment.

Originally this library was intended to be vendored, however since then it is significantly increased in complexity. A stripped down version that is suitable for parsing a minimal sane dialect that can be used as a configuration language may be added in the future.

  • Usage #+begin_src bash git clone https://github.com/tgbugs/sxpyr.git pushd sxpyr pip install --user -e .[cli] python -m sxpyr.cli parse test/data/nested-splicing-unsyntax.rkt test/data/plist-test.sxpr popd #+end_src

  • Testing In order to run the tests you will need the following repos.

  • sbcl
  • ccl
  • emacs
  • org-mode
  • clojure
  • spec.alpha
  • code.specs.alpha
  • tawny-owl
  • hy
  • Fennel
  • txr

For now you will also need the following installed on your system.

  • xemacs
  • app-xemacs/xemacs-packages-all
  • guile
  • gambit
  • Fuzzing You will need a copy of afl. #+begin_src bash pip install --user -e .[fuzz] pushd test mkdir initial-inputs cp data/plist-test.sxpr initial-inputs/ # other seed files can be added as well py-afl-fuzz -m 400 -i initial-inputs/ -o fuzzing-results/ -- python -m sxpyr.cli parse --fuzz #+end_src

#+begin_src bash python -m sxpyr.cli parse test/fuzzing-results/crashes/* #+end_src

Note that initial inputs cannot be symlinks becuase afl creates hardlinks to the input files.

Also note that afl seems to die after 175k execs?

Sometimes it also seems that some errors are escaping the except block and making it be classified as crashes?

Metadata

Release files for sxpyr 0.0.4

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

Source distribution (sdist)

Source distribution for sxpyr 0.0.4
File Size Uploaded
sxpyr-0.0.4.tar.gz 84.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sxpyr 0.0.4
File Interpreter ABI Platform
sxpyr-0.0.4-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 116.9 kB

Release files / sxpyr-0.0.4.tar.gz

Download URL sxpyr-0.0.4.tar.gz
Size 84.2 kB
Tags Source
SHA-256 checksum
How to use checksums
68a070b4996eb514cb878a209e15fa4797389a7b10e6172cb21353f02f5140f9
BLAKE2b-256 checksum
How to use checksums
63df014c20a5c4b1e8335a58c8e59d1d88389804ab153df9a117644dad2eb995
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / sxpyr-0.0.4-py2.py3-none-any.whl

Download URL sxpyr-0.0.4-py2.py3-none-any.whl
Size 32.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b0e4d824055b8ae4e426ebd5e2e61976f973fdcff28af901f38c261dedb3a142
BLAKE2b-256 checksum
How to use checksums
9063134e7feb2b913b81f038d6853b6bcb37feccf29d4af084e1428a2c665aad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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