package edu.neu.ccs.demeter; /** A terminal class for parsing an identifier (a sequence of letters, digits, and underscores not starting with a digit). Put Ident in a class dictionary to represent an identifier in an input sentence. */ final public class Ident implements java.io.Serializable { private String str; /** Construct an Ident from a String. Note that an Ident created outside of the parser is not constrained to be an identifier. */ public Ident(String s) { str = s; } /** Construct an Ident from an Object by converting it to a String with {@link Object#toString()}. Note that an Ident created outside of the parser is not constrained to be an identifier. */ public Ident(Object obj) { str = obj.toString(); } public String toString() { return str; } public int hashCode() { return str.hashCode(); } public boolean equals(Object id) { return (id instanceof Ident) && str.equals(((Ident) id).str); } }