[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Symbol tables and scopes

Angelo Schneider wrote:
> Does SableCC include support for symbol tables and management of
> (nested)scopes?

There comes the magic of OO and Java:-)

1- You design a SymbolTable class, that probably uses a Hashtable object
to associate strings with declaration nodes.
2- You extend your preferred tree walker (probably DepthFirstAdapter),
and use a Stack field to push/pop SymbolTable objects as you enter/leave
a scope.

This is one way of doing it.

Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                             http://www.sablecc.org/
and SableVM:                                   http://www.sablevm.org/