Skip to main content

Mathematica parser and translator

Project description

https://travis-ci.org/rocky/FoxySheep2.svg?branch=master

This is the Robert Jacobson’s Python implementation of the FoxySheep parser and lexer for Mathematica. It has been stripped down and reorganized a bit.

Examples

When installed, the command-line translator is called foxy-sheep which can convert Mathematica InputForm to Mathematica FullForm without having Mathematica installed: To run the code interactively:

$ foxy-sheep
Enter a Mathematica expression. Enter either an empty line, Ctrl-C, or Ctrl-D to exit.
in:= 1+2
Plus[1,2]
in:=D[4 x^2]
D[Times[4,Power[x,2]]]
in:=
$

To call from Python:

from FoxySheep import FullForm_from_string
print(FullForm_from_string("x^2-3x+4"))
# Prints: Plus[Power[x,2],Times[-1,3,x],4]

For help on foxy-sheep, run foxy-sheep --help.

To see a demo run python demo.py in this directory.

Regenerating the lexer/parser

To change the grammar you’ll need the ANTLR Parser Generator (antlr4), version 4.7.x installed.

To (re)generate the lexer/parser you need to

$ make

The resulting files are placed in FoxySheep/generated.

Files generated by ANTLR4 are assumed to be in a subdirectory called generated containing an empty __init__.py file. See the Makefile for details.

FoxySheepLexer Must Subclass Lexer

In order for the generated antlr4 lexer to work we need to patch the generated Python lexer FoxySheep.lexer.py; The patch file FoxySheep.lexer.py.patch does this. The Makefile target for FoxySheepParser.py contains the patch command.

If patching is not done you’ll get an AttributeError exception in the lexer you try to run it such as through foxy-sheep.

AttributeError: 'FoxySheepLexer' object has no attribute 'checkAdditiveOp'

See Also

FoxySheep

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

FoxySheep-1.1.0.tar.gz (82.1 kB view details)

Uploaded Source

Built Distributions

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

FoxySheep-1.1.0-py38-none-any.whl (94.9 kB view details)

Uploaded Python 3.8

FoxySheep-1.1.0-py36-none-any.whl (94.9 kB view details)

Uploaded Python 3.6

FoxySheep-1.1.0-py3.8.egg (230.2 kB view details)

Uploaded Egg

FoxySheep-1.1.0-py3.7.egg (229.8 kB view details)

Uploaded Egg

FoxySheep-1.1.0-py3.6.egg (229.7 kB view details)

Uploaded Egg

FoxySheep-1.1.0-py3-none-any.whl (94.9 kB view details)

Uploaded Python 3

File details

Details for the file FoxySheep-1.1.0.tar.gz.

File metadata

  • Download URL: FoxySheep-1.1.0.tar.gz
  • Upload date:
  • Size: 82.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.4

File hashes

Hashes for FoxySheep-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8b582c0d0c99f3509663d46d267d9fa1451888f76dc4d65949c362b99a549a6f
MD5 bb7789675c1bd6a06a8f03f71868bc5c
BLAKE2b-256 d446a8e79f4505ab958d6eac6515a32030243cae7725b916d9b677feb5399134

See more details on using hashes here.

File details

Details for the file FoxySheep-1.1.0-py38-none-any.whl.

File metadata

  • Download URL: FoxySheep-1.1.0-py38-none-any.whl
  • Upload date:
  • Size: 94.9 kB
  • Tags: Python 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.4

File hashes

Hashes for FoxySheep-1.1.0-py38-none-any.whl
Algorithm Hash digest
SHA256 3c8dad52364010dd4758b6334c18f2b5a07bb74ebff7cc61ae488ed39a50539d
MD5 400819dd47ee3f12b4bda9044817e22f
BLAKE2b-256 395095f7f8249ba4a873885c368718fed4b9d908bcd1d62530c333fa2814eb34

See more details on using hashes here.

File details

Details for the file FoxySheep-1.1.0-py36-none-any.whl.

File metadata

  • Download URL: FoxySheep-1.1.0-py36-none-any.whl
  • Upload date:
  • Size: 94.9 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.4

File hashes

Hashes for FoxySheep-1.1.0-py36-none-any.whl
Algorithm Hash digest
SHA256 73365886e45507d77d9f91c84928571d118eb214e015b4f3e6dbee4d9b875e12
MD5 4a65c0fe69658e02a00107f494301faf
BLAKE2b-256 8817e59ac4177d0e29db147c4a564c8a49af6fc0dccf271ec1231720b6fcc1a8

See more details on using hashes here.

File details

Details for the file FoxySheep-1.1.0-py3.8.egg.

File metadata

  • Download URL: FoxySheep-1.1.0-py3.8.egg
  • Upload date:
  • Size: 230.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.4

File hashes

Hashes for FoxySheep-1.1.0-py3.8.egg
Algorithm Hash digest
SHA256 063ace6f761fbc833a2b67fedf6efd006327db0d796f513085e43a274dc705d4
MD5 747343045c3d61132d2a4cfb195ce72f
BLAKE2b-256 e6cbc228812203e8046923ae997f8f2001408b46cc5cf4690ecdc77d264795ea

See more details on using hashes here.

File details

Details for the file FoxySheep-1.1.0-py3.7.egg.

File metadata

  • Download URL: FoxySheep-1.1.0-py3.7.egg
  • Upload date:
  • Size: 229.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.4

File hashes

Hashes for FoxySheep-1.1.0-py3.7.egg
Algorithm Hash digest
SHA256 9a99ad3457cc1c900443b4a3e042df056dce4fdd1b1a10ce100551501788f41c
MD5 433cb39f5445de57346ffae0700dd217
BLAKE2b-256 460c9c4a15051d436d8188cbdba2a42c7c787c5949107ec36e68dbbb969eb85c

See more details on using hashes here.

File details

Details for the file FoxySheep-1.1.0-py3.6.egg.

File metadata

  • Download URL: FoxySheep-1.1.0-py3.6.egg
  • Upload date:
  • Size: 229.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.4

File hashes

Hashes for FoxySheep-1.1.0-py3.6.egg
Algorithm Hash digest
SHA256 f2683258e25d009d40f79f0979f80042b67f3e6e461fd9f8b855233056202a74
MD5 7da60a07f6dcbb67e65ac866e1eb0811
BLAKE2b-256 12020dc6b4a7902e2102f7b9ccce072fc70bb978d5ee5981261623e8e2fc0987

See more details on using hashes here.

File details

Details for the file FoxySheep-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: FoxySheep-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 94.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.4

File hashes

Hashes for FoxySheep-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f50c39799f32743149d290339228b50183f2a6c5b9b06dd945f4bd3145c1230a
MD5 b5161ddb2cec7ff83ae13bb3e2d279f2
BLAKE2b-256 f9d816aba0033ec50cbd1e87a29af052f17bdcc77099f229529a6515d104730a

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