"David L. Nicol" wrote:
> So what would be involved in adding hooks for arbitrary semantic analysis?

At the most fundamental level all you need is a parse tree with attributes
that you can write constraints against. IMHO there isn't much difference
in technique between "semantic analysis" and "optimization". If you can do
one you can do the other.

The thing that concerns me is that this is a *lot* more involved than a
set of hooks. It might be that the interpreter, compiler (backend code
generator) and VM all have different analysis requirements. For example,
the VM doesn't care if something is meaningful or optimized, just that
it's safe. For taintedness analysis, I think running code through the
compiler might make the most sense. It would reduce the performance
requirements and could provide more information to the programmer.

> What language features can be described to allow for introduction of
> arbitrary SA passes?  At what levels?

Language features would be input to the parse tree attributes -- they
don't allow or disallow analysis. Analysis is part of implementation and
goes under the language -- under the parser in fact. Syntax macros
will probably do some local analysis. (Damian's currying operators will
have to do some analysis to figure out when to stop currying for example.)
It might make sense to have pluggable optimizers instead of hooks for
global analysis though. "use less memory" could load a memory optimizer.
"use safe io" could load the taint analyzer. Maybe these pragmas only
work in the compiler though?

> What's a good introductory glossary of SA terms? Things get confusing
> with many reinvented wheels rolling around.

The dragon book is popular (duh!). I also found

  The Art of Compiler Design
  Thomas Pittman and James Peters
  ISBN 0-13-048190-4

very helpful in understanding attribute grammars. Once you get through
those two,

  Advanced Compiler Design and Implementation
  Steven S. Muchnick
  ISBN 1-55860-320-4

will move you from theory to practice. It has *extensive* coverage
of optimization techniques that will be applicable to semantic
analysis too. (I'm still slogging through it myself.) As long as I'm
listing compiler books, I might as well give my introductory
favorites:

  Modern Compiler Implementation in ML
  Andrew W. Appel
  ISBN 0-521-58274-1

  Very nice introductory book that covers grammars, code generation,
  optimization, garbage collection, "static single assignment" form and
  a lot of other stuff. There are versions of this book for Java and C,
  but I think the ML is best.

  Compiler Design in C
  Allen I. Holub
  ISBN 0-13-155045-4

  An introductory book that's closer to the "use the source
  Luke" philosophy. I really like Holub's writing, so that may bias
  me. Compilers are tough enough subjects though that just reading
  somebody you're comfortable with might make the difference.

- Ken

Reply via email to