It's certainly incomplete, but I started working on a CAS (Computer Algebra
System: http://en.wikipedia.org/wiki/Computer_algebra_system) that was
"backed" by commons-math: https://github.com/wspeirs/math

The JJT (parser file for JavaCC) file can be found here, and is fairly
complete if I remember correctly:
https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt

I'd be happy to help you with it further and/or accept pull requests to
improve it :-)

Bill-


On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <ted.dunn...@gmail.com> wrote:

> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
> mansour.alak...@gmail.com
> > wrote:
>
> > As Luc said, it will big project to write a parser that takes any
> > equation as a string, and generate the matrix (2-dimensional array) to
> > feed it into Commons Math.
> >
>
>
> It actually isn't a big project.
>
> See http://www.antlr.org/
>
> The simplest example they give there is this one:
>
> *grammar Expr;*
> *prog: (expr NEWLINE)* ; *
> *expr: expr ('*'|'/') expr *
> *    | expr ('+'|'-') expr *
> *    | INT | '(' expr ')' ; *
> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
>
> This will compile into a java program that parses expressions very much
> like what you want.
>

Reply via email to