Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parser for the Mathematica syntax?

Is there a built parser that I can use from C# that can parse mathematica expressions?

I know that I can use the Kernel itself to parse an expression, and use .NET/Link to retrieve the tree structure... But I'm looking for something that doesnt rely on the Kernel.

like image 907
Nestor Avatar asked Oct 22 '09 16:10

Nestor


2 Answers

My matheclipse-parser module implements a parser in Java which can parse a big subset of mathematica expressions. See the readme.md page for usage. Maybe you can port the parser to C#?

like image 87
axelclk Avatar answered Oct 04 '22 15:10

axelclk


The mathematica grammar isn't well documented, true. But AFAIK, it is LALR(1) and likely LL(1); the bracketed /tagged syntax from gives the parser complete clues about what to expect next, just like LISP and XML.

The DMS Software Reengineering Toolkit does have a Mathematica grammar that has been used for real tasks. This includes MMa programs as well as pure expression forms.

That probably doesn't help you, since you want one in C#.

If you have access to the Kernal, I'd stick to that.

like image 29
Ira Baxter Avatar answered Oct 04 '22 16:10

Ira Baxter