|Functional Symbol Tables firstname.lastname@example.org (bison) (2007-07-09)|
|Re: Functional Symbol Tables email@example.com (2007-07-13)|
|Re: Functional Symbol Tables firstname.lastname@example.org (A.T.Hofkamp) (2007-07-13)|
|Re: Functional Symbol Tables email@example.com (2007-07-18)|
|From:||firstname.lastname@example.org (Torben =?iso-8859-1?Q?=C6gidius?= Mogensen)|
|Date:||Fri, 13 Jul 2007 09:30:25 +0200|
|Organization:||Department of Computer Science, University of Copenhagen|
|Posted-Date:||15 Jul 2007 16:24:45 EDT|
bison <email@example.com> writes:
> I'm trying to figure out a way to implement symbol tables in a
> functional style, but I can't figure out a way to do that. The only
> way I can think to do it is to keep track of names during parsing for
> each scope and upon entering a scope add these bindings to the
> existing table.
> I read somewhere that you can pass around your ST through arguments.
> My thought about that is that if you are using recursion, you will
> lose all of your mappings once that call is returns. Does anyone have
> any thoughts on this?
The bindings you lose on return are exactly those that go out of
scope, so this is desired behavior.
You can download my book "Basics of Compiler Design" from
[http://www.diku.dk/~torbenm/Basics/index.html]. Chapter 4 is about
symbol tables, discussing imperative versus persistent (functional)
tables, and you can see examples of use of functional symbol tables in
chapters 5 and 6.
Return to the
Search the comp.compilers archives again.