From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] scopes in kencc From: "Russ Cox" Date: Thu, 26 Apr 2007 23:02:39 -0400 In-Reply-To: <7871fcf50704261948j6f33731bvd532e82de4572250@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20070427030241.799051E8C45@holo.morphisms.net> Topicbox-Message-UUID: 503ddcd8-ead2-11e9-9d60-3106f5b1d025 > In my compilers class, the professor suggested using some linked list > of scopes so that lookup would always return the nearest symbol by a > given name (modulo namespace issues). Since there's a single global > symbol table in kencc, what tells lookup to return the properly scoped > symbol? only the properly scoped symbol is in the hash table during the lookup. new declarations replace old ones but the old ones get added to an undo log. when a } is reached, the undo log is applied to put the old ones back. this is a very common "implicit" representation of the scope. appel's book, at least, discusses it as an alternative to the linked-list-of-scopes approach. look for push1 and revertdcl. russ