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

📄 setelem.java

📁 编译原理“龙书”(Compilers: Principles, Techniques, and Tools)中提供的一个小型Syntax-Directed Translator
💻 JAVA
字号:
package inter;import lexer.*; import symbols.*;public class SetElem extends Stmt {   public Id array; public Expr index; public Expr expr;   public SetElem(Access x, Expr y) {      array = x.array; index = x.index; expr = y;      if ( check(x.type, expr.type) == null ) error("type error");   }   public Type check(Type p1, Type p2) {      if ( p1 instanceof Array || p2 instanceof Array ) return null;      else if ( p1 == p2 ) return p2;      else if ( Type.numeric(p1) && Type.numeric(p2) ) return p2;      else return null;   }   public void gen(int b, int a) {      String s1 = index.reduce().toString();      String s2 = expr.reduce().toString();      emit(array.toString() + " [ " + s1 + " ] = " + s2);   }}

⌨️ 快捷键说明

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