#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#    This file is part of arena.
#
#    arena is free software: you can redistribute it and/or modify it
#    under the terms of the GNU General Public License as published by the
#    Free Software Foundation; either version 3 of the License or, at your
#    option, any later version.
#
#    arena is distributed in the hope that it will be useful, but
#    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABLITY
#    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
#    License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with arena.  If not, see <http://www.gnu.org/licenses/>.

## @file
#  This file defines and implements classes that manage symbol tables and
#  collections of symbol tables.

from Library.Memory.Dictionaries import ADictionary
from Library.String.Utilities import String

## Pre-defined scope definitions.
class Scope:
    # The global symbol scope
    globals = 1
    # An undefined scope
    undefined = 0
    # The global types scope
    types = -1

## A symbol table.
class ASymbolTable(ADictionary):
    ## Constructor
    def __init__(Self, thisScope, ThisParent=None):
        ADictionary.__init__(Self)
        
        Self._scope = thisScope        
        Self._Parent = ThisParent

    ## Initializer    
    def init(Self):
        result = ADictionary.init(Self)
        
        if result:
            # Establish private attributes
            # The parent symbol table
            Self._Parent = None
            # The scope of the symbol table
            Self._scope = 0
            
        return result
