Error: duplicate class: llang.Scope

44 views Asked by At

When I compile all my java files for my antlr project, I have a package called llang, and a class, Scope. So, inside my Scope.java file, I have:

package llang;

import java.util.HashMap;
import java.util.Map;
import llang.*;

public class Scope {
    Map<String, Function> memory;
    Map<String, Function> parent;

    public Scope () {
        this(new HashMap<String, Function>());
    }

    public Scope (HashMap<String, Function> parentScope) {
        memory = new HashMap<String, Function>();
        parent = parentScope;
    }

    public void assign (String k, Function v) {
        if (memory.get(k) == null) memory.set(k, v);
    }

    public Function retreive (String k) {
        Function res = memory.get(k);
        if (res == null) return parent.get(k);
        return res;
    }

    public boolean has (String k) {
        return retreive(k) != null;
    }
}

And nowhere in my intire project is another "Scope" class or "Scope" file. Yet, when I compile it, it says:

./Scope.java:7: error: duplicate class: llang.Scope
public class Scope {
             ^

HELP!

1

There are 1 answers

0
Alexis Purslane On

The fix? Remove import llang.* and replace with: import llang.<Whatever other classes>. Thanks, @AndrewTobilko