This module defines a Symboltable optimized for the SQLNamer. It contains two FiniteMaps, both using strings as keys and < as comparison operation. It is parameterized over both value types. Only the first Map is supporting a scope concept.
emptyTable
:: Symboltable a b
|
lookupFirstTable
:: String -> Symboltable a b -> Maybe a
Lookupfunction: First looks up the key in the current scope (first table) if it is not found the surrounding scope will be used and so on. |
lookupCurrentScope
:: String -> Symboltable a b -> Maybe a
Looks up the key just in the current scope of the first table. |
lookupSecondTable
:: String -> Symboltable a b -> Maybe b
Looks up the key in the second table (which does not support scopes). |
insertFirstTable
:: String -> a -> Symboltable a b -> Symboltable a b
Inserts a key-value-pair into the current scope (first table). |
insertDefFirstTab
:: String -> a -> (a -> a -> a) -> Symboltable a b -> Symboltable a b
Inserts a key-value-pair into the current scope (first table) without throwing away previous bindings. |
insertSecondTable
:: String -> a -> Symboltable b a -> Symboltable b a
Inserts a key-value-pair into the second table (which does not support scopes). |
enterScope
:: Symboltable a b -> Symboltable a b
Create a new scope inside the last one (first table, leaving the secong one unchanged). |
exitScope
:: Symboltable a b -> Symboltable a b
Exits current scope, so that the surrounding one will be used. |
combineST
:: Symboltable a b -> Symboltable a b -> Symboltable a b
Combines two Symboltables. |
A Symboltable consists of at least one pair of FiniteMaps. There can be another table representing a surrounding scope.
Constructors:
ST
:: (FM String a,FM String b) -> (Maybe (Symboltable a b)) -> Symboltable a b
|
Lookupfunction: First looks up the key in the current scope (first table) if it is not found the surrounding scope will be used and so on. Returns Nothing if no value was found. |
Looks up the key just in the current scope of the first table. |
Looks up the key in the second table (which does not support scopes). |
Inserts a key-value-pair into the current scope (first table). |
Inserts a key-value-pair into the current scope (first table) without throwing away previous bindings. Values are combined by given combinator. |
Inserts a key-value-pair into the second table (which does not support scopes). |
Create a new scope inside the last one (first table, leaving the secong one unchanged). |
Exits current scope, so that the surrounding one will be used. If the current scope is the most general one, nothing will be changed.
|
Combines two Symboltables. The current Scopes will be merged, all the remaining scopes are taken from the first table. Bindings for the same key will be overwritten by the binding in the current scope. |