错误:重复的类:llang.Scope

时间:2015-06-08 16:07:44

标签: java antlr4

当我编译我的antlr项目的所有java文件时,我有一个名为llang的包和一个类Scope。所以,在我的Scope.java文件中,我有:

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;
    }
}

在我的服装项目中没有任何地方是另一个&#34; Scope&#34; class or&#34; Scope&#34;文件。然而,当我编译它时,它说:

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

HELP!

1 个答案:

答案 0 :(得分:0)

修复?移除import llang.*并替换为:import llang.<Whatever other classes>。谢谢,@ AndrewTobilko