On 25 February 2011 10:48, Ira Baxter <idbax...@semdesigns.com> wrote:
> On Feb 25, 3:05 am, David Kirkby <david.kir...@onetel.net> wrote:
>> On 25 February 2011 05:57, Ira Baxter <idbax...@semdesigns.com> wrote:
>>
>> > Mathematica is otherwise not hard to parse, and you don't need
>> > a hand-written parser to do it.
>>
>> > Ira D. Baxter, CTO
>> > Semantic Designs, Inc.
>
> Part of this discussion started because Dave suggested that
> writing and maintaining a hand-written parser was harder
> than a parser-generator one,

That's the impression I've got from spending a bit of time on reading
compiler books. I personally don't have a computer science background,
so have very little knowledge of this area, whereas clearly this is
one of your areas of expertise.

> and consequently that Wolfram
> probably didn't write a parser by hand.

Wolfram is a bright guy, so I concluded (perhaps incorrectly), he
would have done it the easiest way possible. I got the impression that
would have been to use pre-written tools for the lexical analysis and
parsing, rather than hand craft them, which I understood had high
maintenance costs.

> Writing a top-down recursive descent parser isn't terribly hard for
> a lot of languages; I've done many this way.
> Mathematica in fact is probably singularly
> easy, because of its Lisp-like syntax.   Lisp parsers have been
> pretty much hand-rolled from day one because of this
> rather simply notation with convenient brackets to
> guide the parser as to when to push, and when to pop.

Richard Fateman has written a parser for Mathematica in Lisp

http://www.eecs.berkeley.edu/~fateman/papers/lmath.ps

I was interested if his comments in the section "Lexical Analysis and
Parsing" and as to how accurate they are.

His code is public

http://www.cs.berkeley.edu/~fateman/mma1.6/

I personally find Richard can be helpful, but some of his comments
(like those directed at you and your company) are somewhat less than
helpful.

He wrote a review of Mathematica some time ago.

http://www.math.bme.hu/~jtoth/FelsMma/mma.review.pdf


> The rumors that I heard was the the early versions of MMa
> were based in Fortran.  My guess is that Wolfram did write
> a recursive descent parser by hand, because you can do that
> easily even in Fortran.

Would you mind answering the following question, and I would not blame
you if you chose not to!

If someone wanted to write an open-source, cross-platform parser for
Mathematica, without using commercial tools like that produced by your
company, what approach (or approaches) would you consider sensible
ones? Would this be easier in Lisp than in say C or Python?

> I would further guess there isn't/wasn't any great reason to change
> it.

That makes sense,

> Final remark: the effort to write the parser is tiny compared to
> the effort to build the rest of any interesting system attached
> to a parser.  The same is true for maintenance costs.

Yes, that's clear. But Sage does have a reasonable subset (and in some
cases superset) of Mathematica, so hooking up a Mathematica parser to
Sage (which is basically Python-like), could have some uses and would
not involve writing all of Mathematica.

However, the approach of an open-source multi-platform clone of
Mathematica, no using Sage (but some components of it, such an MPIR,
MPFR etc), would be an interesting open-source project.

> Ira Baxter, CTO
> Semantic Designs

Anyway, thank you Ira. You have convinced me that Richards numbers 1 &
3 were wrong.

Dave

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to