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

📄 production_part.java

📁 我开发的一个用java语言实现的编译器,内含词法分析器,语法分析器,而且可以实现中间代码生成.用到了SLR算法和LR(1)算法
💻 JAVA
字号:
package java_cup;/** This class represents one part (either a symbol or an action) of a  *  production.  In this base class it contains only an optional label  *  string that the user can use to refer to the part within actions.<p> * *  This is an abstract class. * * @see     java_cup.production * @version last updated: 11/25/95 * @author  Scott Hudson */public abstract class production_part {  /*-----------------------------------------------------------*/  /*--- Constructor(s) ----------------------------------------*/  /*-----------------------------------------------------------*/         /** Simple constructor. */  public production_part(String lab)    {      _label = lab;    }  /*-----------------------------------------------------------*/  /*--- (Access to) Instance Variables ------------------------*/  /*-----------------------------------------------------------*/         /** Optional label for referring to the part within an action (null for    *  no label).    */  protected String _label;  /** Optional label for referring to the part within an action (null for    *  no label).    */  public String label() {return _label;}  /*-----------------------------------------------------------*/  /*--- General Methods ---------------------------------------*/  /*-----------------------------------------------------------*/         /** Indicate if this is an action (rather than a symbol).  Here in the    * base class, we don't this know yet, so its an abstract method.   */  public abstract boolean is_action();  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/  /** Equality comparison. */  public boolean equals(production_part other)    {      if (other == null) return false;      /* compare the labels */      if (label() != null)	return label().equals(other.label());      else	return other.label() == null;    }  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/  /** Generic equality comparison. */  public boolean equals(Object other)    {      if (!(other instanceof production_part))        return false;      else	return equals((production_part)other);    }  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/  /** Produce a hash code. */  public int hashCode()    {      return label()==null ? 0 : label().hashCode();    }  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/  /** Convert to a string. */  public String toString()    {      if (label() != null)	return label() + ":";      else	return " ";    }  /*-----------------------------------------------------------*/}

⌨️ 快捷键说明

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