📄 literal.java
字号:
package AST;
import java.util.HashSet;import java.util.LinkedHashSet;import java.io.FileNotFoundException;import java.io.File;import java.util.*;import beaver.*;import java.util.ArrayList;import java.util.zip.*;import java.io.*;public abstract class Literal extends PrimaryExpr implements Cloneable {
public void flushCache() { super.flushCache(); constant_visited = -1; constant_computed = false; constant_value = null; isConstant_visited = -1; dumpString_visited = -1; } @SuppressWarnings({"unchecked", "cast"}) public Literal clone() throws CloneNotSupportedException { Literal node = (Literal)super.clone(); node.constant_visited = -1; node.constant_computed = false; node.constant_value = null; node.isConstant_visited = -1; node.dumpString_visited = -1; node.in$Circle(false); node.is$Final(false); return node; } // Declared in ConstantExpression.jrag at line 160 static long parseLong(String s) { long x = 0L; s = s.toLowerCase(); int radix = 10; boolean neg = false; if(s.startsWith("0x")) { radix = 16; s = s.substring(2); if(s.length() > 16) { for(int i = 0; i < s.length()-16; i++) if(s.charAt(i) != '0') throw new NumberFormatException(""); } } else if(s.startsWith("0")) { radix = 8; s = s.substring(1); // Octals larger than 01777777777777777777777L are not valid if(s.length() > 21) { for(int i = 0; i < s.length() - 21; i++) if(i == s.length() - 21 - 1) { if(s.charAt(i) != '0' && s.charAt(i) != '1') throw new NumberFormatException(""); } else { if(s.charAt(i) != '0') throw new NumberFormatException(""); } } } else if(s.startsWith("-")) { s = s.substring(1); neg = true; } long oldx = 0; for (int i = 0; i < s.length(); i++) { int c = s.charAt(i); if (c < '0' || c > '9') { c = c - 'a' + 10; } else { c = c - '0'; } x *= radix; x += c; if(x < oldx && radix == 10) { boolean negMinValue = i == (s.length()-1) && neg && x == Long.MIN_VALUE; if(!negMinValue) throw new NumberFormatException(""); } oldx = x; } if(radix == 10 && x == Long.MIN_VALUE) return x; if(radix == 10 && x < 0) { throw new NumberFormatException(""); } return neg ? -x : x; } // Declared in PrettyPrint.jadd at line 281 // Literals public void toString(StringBuffer s) { s.append(getLITERAL()); } // Declared in PrettyPrint.jadd at line 308 protected static String escape(String s) { StringBuffer result = new StringBuffer(); for (int i=0; i < s.length(); i++) { switch(s.charAt(i)) { case '\b' : result.append("\\b"); break; case '\t' : result.append("\\t"); break; case '\n' : result.append("\\n"); break; case '\f' : result.append("\\f"); break; case '\r' : result.append("\\r"); break; case '\"' : result.append("\\\""); break; case '\'' : result.append("\\\'"); break; case '\\' : result.append("\\\\"); break; default: int value = (int)s.charAt(i); if(value < 0x20 || (value > 0x7e)) result.append(asEscape(value)); else result.append(s.charAt(i)); } } return result.toString(); } // Declared in PrettyPrint.jadd at line 330 protected static String asEscape(int value) { StringBuffer s = new StringBuffer("\\u"); String hex = Integer.toHexString(value); for(int i = 0; i < 4-hex.length(); i++) s.append("0"); s.append(hex); return s.toString(); } // Declared in java.ast at line 3 // Declared in java.ast line 124
public Literal() { super();
} // Declared in java.ast at line 10
// Declared in java.ast line 124 public Literal(String p0) { setLITERAL(p0); } // Declared in java.ast at line 15 // Declared in java.ast line 124 public Literal(beaver.Symbol p0) { setLITERAL(p0); } // Declared in java.ast at line 19 protected int numChildren() {
return 0;
} // Declared in java.ast at line 22
public boolean mayHaveRewrite() { return false; } // Declared in java.ast at line 2 // Declared in java.ast line 124 private String tokenString_LITERAL; // Declared in java.ast at line 3 public void setLITERAL(String value) { tokenString_LITERAL = value; } // Declared in java.ast at line 6 public int LITERALstart; // Declared in java.ast at line 7 public int LITERALend; // Declared in java.ast at line 8 public void setLITERAL(beaver.Symbol symbol) { if(symbol.value != null && !(symbol.value instanceof String)) throw new UnsupportedOperationException("setLITERAL is only valid for String lexemes"); tokenString_LITERAL = (String)symbol.value; LITERALstart = symbol.getStart(); LITERALend = symbol.getEnd(); } // Declared in java.ast at line 15 public String getLITERAL() { return tokenString_LITERAL != null ? tokenString_LITERAL : ""; } protected int constant_visited = -1; protected boolean constant_computed = false; protected Constant constant_value; // Declared in ConstantExpression.jrag at line 103 @SuppressWarnings({"unchecked", "cast"}) public Constant constant() { if(constant_computed) return constant_value; if(constant_visited == boundariesCrossed) throw new RuntimeException("Circular definition of attr: constant in class: "); constant_visited = boundariesCrossed; int num = boundariesCrossed; boolean isFinal = this.is$Final(); constant_value = constant_compute(); if(isFinal && num == boundariesCrossed) constant_computed = true; constant_visited = -1; return constant_value; } private Constant constant_compute() { throw new UnsupportedOperationException("ConstantExpression operation constant" + " not supported for type " + getClass().getName()); } protected int isConstant_visited = -1; // Declared in ConstantExpression.jrag at line 467 @SuppressWarnings({"unchecked", "cast"}) public boolean isConstant() { if(isConstant_visited == boundariesCrossed) throw new RuntimeException("Circular definition of attr: isConstant in class: "); isConstant_visited = boundariesCrossed; boolean isConstant_value = isConstant_compute(); isConstant_visited = -1; return isConstant_value; } private boolean isConstant_compute() { return true; } protected int dumpString_visited = -1; // Declared in PrettyPrint.jadd at line 795 @SuppressWarnings({"unchecked", "cast"}) public String dumpString() { if(dumpString_visited == boundariesCrossed) throw new RuntimeException("Circular definition of attr: dumpString in class: "); dumpString_visited = boundariesCrossed; String dumpString_value = dumpString_compute(); dumpString_visited = -1; return dumpString_value; } private String dumpString_compute() { return getClass().getName() + " [" + getLITERAL() + "]"; }public ASTNode rewriteTo() { return super.rewriteTo();}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -