Re: Choosing a parser for Mathematica input

Robert Jacobson <rljacobson@gmail.com>
Fri, 6 Feb 2015 19:04:08 -0800 (PST)

          From comp.compilers

Related articles
[3 earlier articles]
Re: Choosing a parser for Mathematica input drkirkby@gmail.com (David Kirkby) (2010-11-09)
Re: Choosing a parser for Mathematica input winkzhang@gmail.com (Wink Zhang) (2010-11-13)
Re: Choosing a parser for Mathematica input idbaxter@semdesigns.com (Ira Baxter) (2010-11-26)
Re: Choosing a parser for Mathematica input drkirkby@gmail.com (David Kirkby) (2010-11-26)
Re: Choosing a parser for Mathematica input drkirkby@gmail.com (David Kirkby) (2010-11-27)
Re: Choosing a parser for Mathematica input fateman@gmail.com (2015-02-05)
Re: Choosing a parser for Mathematica input rljacobson@gmail.com (Robert Jacobson) (2015-02-06)
| List of all articles for this month |

From: Robert Jacobson <rljacobson@gmail.com>
Newsgroups: comp.compilers
Date: Fri, 6 Feb 2015 19:04:08 -0800 (PST)
Organization: Compilers Central
References: 10-11-017 15-02-009
Keywords: parse
Posted-Date: 06 Feb 2015 22:16:11 EST

I am among those who are trying to write a Mathematica parser. There are a few
Mathematica parsers out there.


* Richard Fateman's old MockMMA of course (written in Lisp) which is mentioned
in the first post of this thread from 2010.


* This MIT-licensed parser written in Scala is notable. Written by Mateusz
Paprocki "and contributors" a couple of years ago.
https://github.com/mattpap/mathematica-parser


* Alex Gittens's basicCAS is a python Mathematica parser, but it appears to
have disappeared from the author's website. It's still available elsewhere on
the net for those interested in looking for it. This project is interesting
because it includes Alex's notes regarding implementation.
https://pypi.python.org/pypi/basicCAS/1.0


* Mathics, a Mathematica clone written in Python and created by Jan Pvschko,
is particularly interesting. You can use it online. GPL licensed, copyright
2007.
http://www.mathics.org


* omath is similar in spirit to Mathics but is written in Java and appears to
have been abandoned at version 10^(-16) in 2005. The parser is a generated
parser using JavaCC and JJTree. The source code is distributed without a
license.
http://omath.org/w/index.php?title=Main_Page


* symja contains a Mathematica parser for a reasonable subset of Mathematica.
https://code.google.com/p/symja/source/browse/#svn/trunk/matheclipse-parser


SymPy and Sage both have rudimentary Mathematica parsers that work for basic
mathematical expressions. There are also some (rumors of) proprietary
Mathematica parsers. John Herrop of Flying Frog Consultancy claims to have
written a Mathematica parser in 300 lines of OCaml under contract for Wolfram
Research. The code is obviously not publicly available. Semantic Designs, a
company specializing in compiler technologies, lists Mathematica among the
many languages for which it has "front ends." (Both mentioned here:
http://stackoverflow.com/questions/1608380/parser-for-the-mathematica-syntax.
)


Wolfram Research may be grotesquely litigious, but given the existence of so
many of these projects it seems to me they are no longer interested in suing
everyone who even thinks the word Mathematica as they once were.


My own project is to construct an ANTLR4 grammar for Mathematica. Such a
grammar seems to me to be the easiest way to benefit the most people with
current compiler technologies. ANTLR4 has c#, python, java, and javascript
targets (some better than others), and a c/c++ target is allegedly in the
works. Several projects have expressed interest in such a thing, but it
appears nobody has succeeded in producing it. I am very happy with how far I
was able to get with very little effort, but my grammar isn't yet ready for
public consumption (read: doesn't work). See my top-level post to this
community for an example of one of the problems I'm still trying to solve with
my project.


Best,


Robert


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.