On Feb 25, 2:48 am, 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, and consequently that Wolfram
> probably didn't write a parser by hand.

Unless a language changes, it is not often that one is compelled
to change a parser.  There are lots of reasons not to change a
language.

Which is harder .. changing a hand-written (typically the only
plausible technique is
recursive descent), parser  vs.  changing the syntax table and
augments
for a (say) LALR or perhaps GLR parser?  Why Dave should have an
educated
opinion on this, who knows. He claims to not be an expert, and I
accept that assessment.

>
> 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.

I suspect you do not mean syntax here, unless you mean FullForm.

>  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.

Um, there are a bunch of things wrong with this simple sentence.
1. Programs that read lisp are called readers, not parsers.
One can write a lisp reader for traditional lisp symbolic
expressions in a few lines of code.
2. That code would not include any instructions like "push" or
"pop".  It would be a set of mutually recursive programs to
read atoms and to read lists or "dotted pairs".
3. Common Lisp has a highly customizable reader, where
programs can be attached to characters. This is fairly hairy.



>
> 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.

I am unaware of such rumors, but it sounds pretty doubtful.
Wolfram and friends wrote SMP at Caltech. I think that Wolfram
was able to write programs in C.
>
> I would further guess there isn't/wasn't any great reason to change
> it.
> 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.

I agree.  For example, I find that merely parsing the language is a
lisp program
of about 1,300 lines. The pattern matcher is about that size, as
is the display program.  Doing polynomial and rational arithmetic
is again comparable in size to the parser.

RJF

-- 
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