package test.antlr.pie;
/***
* Excerpted from "Language Implementation Patterns",
* published by The Pragmatic Bookshelf.
* Copyrights apply to this code. It may not be used to create training material,
* courses, books, articles, and the like. Contact us if you are in doubt.
* We make no guarantees that this code is fit for any purpose.
* Visit http://www.pragmaticprogrammer.com/titles/tpdsl for more book information.
***/
import java.util.Map;
import java.util.LinkedHashMap;
public class StructSymbol extends ScopedSymbol implements Scope {
Map<String, Symbol> fields = new LinkedHashMap<String, Symbol>();
public StructSymbol(String name,Scope parent) {super(name, parent);}
/** For a.b, only look in a only to resolve b, not up scope tree */
public Symbol resolveMember(String name) { return fields.get(name); }
public Map<String, Symbol> getMembers() { return fields; }
public String toString() {
return "struct "+name+":{"+fields.keySet().toString()+"}";
}
}