More Mathematica functions in Maxima



 

> -----Original Message-----
> From: John Lapeyre [mailto:pdl at johnlapeyre.com] 
>....
 But, I wonder to what extent the Mmma
> grammar is compatible with an LL parser generator and what
> problems that might cause.

If you developed a grammar for Mathematica, then you could use
a parser generator.  Wolfram does not supply a grammar, unusual
for someone claiming to have a well-designed programming language.

You might find it interesting to develop a grammar.

I believe there is no context-free grammar for the Mathematica language,
and thus in particular it is not LL(n) for any n, nor is it
LR(n) or LALR(n).  The MockMMA parser is mostly recursive descent
but with a number of special cases. If the Perl recursive descent
parser is slow, it is presumably because Perl is slow. There is nothing
inherently slow about recursive descent parsing.

If you took a mathematica definition and wrote it out in FullForm
(using Mathematica), and wanted to parse that, you would be able
to do that fairly trivially. Perhaps 20 lines of Lisp.

Essentially you would be taking the form  
X[Y,Z]   and transforming it to  (X Y Z)

most of the code would be to deal with strange "atoms" like peculiar
numbers, I suspect.

RJF



> I'm certainly not committed to
> Parse::RecDescent; its reputed to be very flexible and very
> slow. I just downloaded mockmma, and I'll look at it.  For
> myself, not being a lisp guru, I like the idea of using a
> parser generator with a user base for support, but I don't
> know how important that is.
> 
> Anyone else have opinons on parser generators?
> 
> It would be easiest to first parse Mma FullForm and
> translate to something equivalent in Maxima ( eg. "*"(2,3) )
> and then add support for infix operators later. I'll
> generate the FullForm code when I get access to Mma, but I
> can't now. For now I have been working on building a tree in
> the natural form (FullForm) and flagging operators to note
> wheter they were infix'ed in the source code, so that a choice
> can be made as to what to do on output.
> 
> There is some flexibility in how things are done. ie, one could
> write the Mma For[,,,] construct in Maxima or translate it
> to "for i thru ... " with the parser. 
> 
> 
> John
> 
> 
> 
>