/*
    Copyright 2016 Yury Benesh
    see COPYING.txt
 */
package org.miod.program;

import java.util.HashMap;
import java.util.Map;
import org.miod.program.errors.SymbolRedefinitionError;

/**
 *
 * @author yur
 */
public abstract class BaseSymbolTable implements SymbolTable {
    private Map<String, SymItem> items = new HashMap<>();
    protected SymbolTable parent;
    
    BaseSymbolTable(SymbolTable parent) {
        this.parent = parent;
    }

    @Override
    public SymItem get(String id) {
        return items.get(id);
    }

    @Override
    public void put(String id, SymItem item) {
        if (get(id) == null) {
            items.put(id, item);
        } else {
            throw new SymbolRedefinitionError(item);
        }
    }

    @Override
    public SymItem resolve(String id) {
        // TODO use parent
        // TODO split by "::" and try to resolve
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    
    
    
}

@@ -360,24 +360,77 @@
 ble parent;%0A
+    public static final String NAMESPACE_SEP = %22::%22;%0A
     %0A    Bas
@@ -942,69 +942,182 @@
     
-throw new UnsupportedOperationException(%22Not supported yet.%22)
+if (id.startsWith(NAMESPACE_SEP)) %7B%0A            if (parent != null)%0A                return parent.resolve(id.substring(NAMESPACE_SEP.length()));%0A        %7D%0A        return null
 ;%0A  

resolve WIP