A handful of LISP questions

tactics <tactics40@gmail.com>
Tue, 19 Jun 2007 00:29:59 -0000

          From comp.compilers

Related articles
A handful of LISP questions tactics40@gmail.com (tactics) (2007-06-19)
Re: A handful of LISP questions gene.ressler@gmail.com (Gene) (2007-06-19)
Re: A handful of LISP questions nmh@t3x.org (Nils M Holm) (2007-06-19)
Re: A handful of LISP questions mcr@nerdware.org (Martin Rodgers) (2007-06-19)
Re: A handful of LISP questions mal@wyrd.be (Lieven Marchand) (2007-06-19)
Re: A handful of LISP questions ahz@snafu.de (Andreas Hinze) (2007-06-19)
Re: A handful of LISP questions tactics40@gmail.com (tactics) (2007-06-20)
[1 later articles]
| List of all articles for this month |

From: tactics <tactics40@gmail.com>
Newsgroups: comp.compilers
Date: Tue, 19 Jun 2007 00:29:59 -0000
Organization: Compilers Central
Keywords: Lisp, parse, question
Posted-Date: 18 Jun 2007 21:51:59 EDT

Hello all~

Recently, I have become interested writing a personal dialect of LISP
in C. Over the last month, I actually managed to get fairly stable
version working and I wrote a small word-guessing game in it and some
common recursive functions (eg, I got it to print the primes between 2
and 100). It was really fun to do, and I want to take it a step
further. However, I have some questions and advice to ask here.

My first question, and the most important to me for now, I think, is
what is the best way to write a parser for a LISP? It was only out of
the grace of the C Gods that I got my current parser working. I have a
nice method for breaking a raw string into tokens (which I was cute
about, and instead of returning an array of tokens, it returns a
cons'ed list of C structure LISP-objects). But once I have the tokens,
I do some pretty bad black magic to get the final list structure. It's
something like, whenever I come to a parenthesis, I search for the
close, split the string, and then parse the stuff inside the paren and
then the stuff outside the paren. It's really bad!

I was wondering from a theoretical standpoint, what kind of grammar is
a LISP grammar? Obviously, it's a straightforward CFG, but is it
LL(1)? I took a class in Programming Languages in college, but nothing
more than how to write a calculator in JavaCC. The web resources for
LL and LR parsing methods are quiet pathetic too (someone needs to
clean up their LL algorithm explanation really badly). Can anyone
point me in the right direction here? What would be a good technique
to look into for this job?

My next question is about garbage collection. I have a nice mark and
sweep algorithm written, but the big issue here is I don't know when
to actually DO garbage collection. Right now, I just call it at the
end of my program, but that is hardly useful. Do I just run it
periodically in a separate thread? Do I set a recurring signal timer?
In either case, what is the best way to ensure I still have access to
the current environment?

If I think of any more questions, I'll post them here. I hope someone
can give me some good advice on these topics.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.