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

📄 table.java

📁 编译原理大作业---tiger编译器 包括semant,translate,mipsframe,regalloc等所有phase 懂的人自会知道
💻 JAVA
字号:
package Symbol;class Binder {  Object value;  Symbol prevtop;  Binder tail;  Binder(Object v, Symbol p, Binder t) { value = v; prevtop = p; tail = t; }}/** * The Table class is similar to java.util.Dictionary, except that * each key must be a Symbol and there is a scope mechanism. */public class Table {  private java.util.Dictionary dict = new java.util.Hashtable();  private Symbol top;  private Binder marks;  public Table(){} /**  * Gets the object associated with the specified symbol in the Table.  */  public Object get(Symbol key) {    Binder e = (Binder)dict.get(key);    if (e==null) return null;    else return e.value;  } /**  * Puts the specified value into the Table, bound to the specified Symbol.  */  public void put(Symbol key, Object value) {    dict.put(key, new Binder(value, top, (Binder)dict.get(key)));    top = key;  } /**  * Remembers the current state of the Table.  */  public void beginScope() {marks = new Binder(null,top,marks); top=null;} /**  * Restores the table to what it was at the most recent beginScope  * that has not already been ended.  */  public void endScope() {    while (top!=null) {       Binder e = (Binder)dict.get(top);       if (e.tail!=null) dict.put(top,e.tail);       else dict.remove(top);       top = e.prevtop;    }    top=marks.prevtop;    marks=marks.tail;  }  /**   * Returns an enumeration of the Table's symbols.   */  public java.util.Enumeration keys() { return dict.keys();}}

⌨️ 快捷键说明

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