⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 set.java

📁 JAVA在编译原理上的应用。
💻 JAVA
字号:
package lolo.scans;/** A recognizer class to scan for a character from a set of characters.  * * @author <a href="http://www.inf.uos.de/bernd" target="_blank">Bernd K&uuml;hl</a>           (<a href="mailto:bernd@informatik.uni-osnabrueck.de">bernd@informatik.uni-osnabrueck.de</a>) */public class Set extends Scan {    /** The set of characters. */    protected final String set;    /** Marks if the symbol character has to be inside or outside <tt>set</tt>. */    protected final boolean inside;    /** Just calls <tt>this(set, true)</tt>.     *     * @param set the set of characters.     * @throws IllegalArgumentException is <tt>set</tt> is <tt>null</tt>.     */    public Set(String set) throws IllegalArgumentException {        this(set, true);    }    /** Constructs a recognizer which scans one character from a set of characters.     * If <tt>inside</tt> is <tt>true</tt> the character has to be inside <tt>set</tt>,     * else outside <tt>set</tt>.     *     * @param set the set of characters.     * @param inside marks if the scanned character has to be inside or outside <tt>set</tt>.     * @throws IllegalArgumentException if <tt>set</tt> is <tt>null</tt>.     */    public Set(String set, boolean inside) throws IllegalArgumentException {        if (set == null)            throw new IllegalArgumentException("set == null");        this.set = set;        this.inside = inside;    }        public void reset() {}    public State nextChar(char ch) {        return stateObject.set(            false,                      // more characters ?            inside ?                    // found symbol ?                set.indexOf(ch) >= 0 :                set.indexOf(ch) < 0        );    }    /** Indicates whether some other object is &quot;equal to&quot; this one.     *      * @return <tt>true</tt> the argument is a <tt>Set</tt> and contains the same set,     * <tt>false</tt> otherwise.     */    public boolean equals(Object o) {        if (o == null || !(o instanceof Set)) return false;        Set s = (Set) o;        return this == s || (set.equals(s.set) && inside == s.inside);    }    /** Returns a hash code value for this object.     *     * @return a hash code value for this object.     */    public int hashCode() {        return set.hashCode();    }        /** Returns a string representation of the object.     *     * @return a string representation of the object.     */    public String toString() {        return getClass().getName()+"["+set+","+inside+"]";    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -