001 /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */ 002 package org.extendj.ast; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.Set; 007 import java.util.Collections; 008 import java.util.Collection; 009 import java.util.ArrayList; 010 import beaver.*; 011 import java.util.*; 012 import java.io.ByteArrayOutputStream; 013 import java.io.PrintStream; 014 import java.lang.reflect.InvocationTargetException; 015 import java.lang.reflect.Method; 016 import org.jastadd.util.*; 017 import java.util.zip.*; 018 import java.io.*; 019 import org.jastadd.util.PrettyPrintable; 020 import org.jastadd.util.PrettyPrinter; 021 import java.io.FileNotFoundException; 022 import java.io.BufferedInputStream; 023 import java.io.DataInputStream; 024 /** 025 * Literal produced when the compiler tries to parse 026 * a malformatted NumericLiteral. 027 * This literal kind has an associated error message. 028 * @ast node 029 * @declaredat /home/jesper/git/extendj/java7/grammar/Literals.ast:11 030 * @production IllegalLiteral : {@link Literal}; 031 032 */ 033 public class IllegalLiteral extends Literal implements Cloneable { 034 /** 035 * Error processing for literals. 036 * Include the token range from parsing. 037 * @aspect Java7Literals 038 * @declaredat /home/jesper/git/extendj/java7/frontend/Literals.jrag:508 039 */ 040 public void collectErrors() { 041 int line = getLine(LITERALstart); 042 int column = getColumn(LITERALstart); 043 int endLine = getLine(LITERALend); 044 int endColumn = getColumn(LITERALend); 045 compilationUnit().errors.add(new Problem(sourceFile(), 046 getLITERAL(), line, column, endLine, endColumn, 047 Problem.Severity.ERROR, Problem.Kind.LEXICAL)); 048 } 049 /** 050 * @declaredat ASTNode:1 051 */ 052 public IllegalLiteral() { 053 super(); 054 } 055 /** 056 * Initializes the child array to the correct size. 057 * Initializes List and Opt nta children. 058 * @apilevel internal 059 * @ast method 060 * @declaredat ASTNode:10 061 */ 062 public void init$Children() { 063 } 064 /** 065 * @declaredat ASTNode:12 066 */ 067 public IllegalLiteral(String p0) { 068 setLITERAL(p0); 069 } 070 /** 071 * @declaredat ASTNode:15 072 */ 073 public IllegalLiteral(beaver.Symbol p0) { 074 setLITERAL(p0); 075 } 076 /** 077 * @apilevel low-level 078 * @declaredat ASTNode:21 079 */ 080 protected int numChildren() { 081 return 0; 082 } 083 /** 084 * @apilevel internal 085 * @declaredat ASTNode:27 086 */ 087 public boolean mayHaveRewrite() { 088 return false; 089 } 090 /** 091 * @apilevel internal 092 * @declaredat ASTNode:33 093 */ 094 public void flushAttrCache() { 095 super.flushAttrCache(); 096 type_reset(); 097 } 098 /** 099 * @apilevel internal 100 * @declaredat ASTNode:40 101 */ 102 public void flushCollectionCache() { 103 super.flushCollectionCache(); 104 } 105 /** 106 * @apilevel internal 107 * @declaredat ASTNode:46 108 */ 109 public void flushRewriteCache() { 110 super.flushRewriteCache(); 111 } 112 /** 113 * @apilevel internal 114 * @declaredat ASTNode:52 115 */ 116 public IllegalLiteral clone() throws CloneNotSupportedException { 117 IllegalLiteral node = (IllegalLiteral) super.clone(); 118 return node; 119 } 120 /** 121 * @apilevel internal 122 * @declaredat ASTNode:59 123 */ 124 public IllegalLiteral copy() { 125 try { 126 IllegalLiteral node = (IllegalLiteral) clone(); 127 node.parent = null; 128 if (children != null) { 129 node.children = (ASTNode[]) children.clone(); 130 } 131 return node; 132 } catch (CloneNotSupportedException e) { 133 throw new Error("Error: clone not supported for " + getClass().getName()); 134 } 135 } 136 /** 137 * Create a deep copy of the AST subtree at this node. 138 * The copy is dangling, i.e. has no parent. 139 * @return dangling copy of the subtree at this node 140 * @apilevel low-level 141 * @deprecated Please use treeCopy or treeCopyNoTransform instead 142 * @declaredat ASTNode:78 143 */ 144 @Deprecated 145 public IllegalLiteral fullCopy() { 146 return treeCopyNoTransform(); 147 } 148 /** 149 * Create a deep copy of the AST subtree at this node. 150 * The copy is dangling, i.e. has no parent. 151 * @return dangling copy of the subtree at this node 152 * @apilevel low-level 153 * @declaredat ASTNode:88 154 */ 155 public IllegalLiteral treeCopyNoTransform() { 156 IllegalLiteral tree = (IllegalLiteral) copy(); 157 if (children != null) { 158 for (int i = 0; i < children.length; ++i) { 159 ASTNode child = (ASTNode) children[i]; 160 if (child != null) { 161 child = child.treeCopyNoTransform(); 162 tree.setChild(child, i); 163 } 164 } 165 } 166 return tree; 167 } 168 /** 169 * Create a deep copy of the AST subtree at this node. 170 * The subtree of this node is traversed to trigger rewrites before copy. 171 * The copy is dangling, i.e. has no parent. 172 * @return dangling copy of the subtree at this node 173 * @apilevel low-level 174 * @declaredat ASTNode:108 175 */ 176 public IllegalLiteral treeCopy() { 177 doFullTraversal(); 178 return treeCopyNoTransform(); 179 } 180 /** 181 * @apilevel internal 182 * @declaredat ASTNode:115 183 */ 184 protected boolean is$Equal(ASTNode node) { 185 return super.is$Equal(node) && (tokenString_LITERAL == ((IllegalLiteral)node).tokenString_LITERAL); 186 } 187 /** 188 * Replaces the lexeme LITERAL. 189 * @param value The new value for the lexeme LITERAL. 190 * @apilevel high-level 191 */ 192 public void setLITERAL(String value) { 193 tokenString_LITERAL = value; 194 } 195 /** 196 * JastAdd-internal setter for lexeme LITERAL using the Beaver parser. 197 * @param symbol Symbol containing the new value for the lexeme LITERAL 198 * @apilevel internal 199 */ 200 public void setLITERAL(beaver.Symbol symbol) { 201 if (symbol.value != null && !(symbol.value instanceof String)) 202 throw new UnsupportedOperationException("setLITERAL is only valid for String lexemes"); 203 tokenString_LITERAL = (String)symbol.value; 204 LITERALstart = symbol.getStart(); 205 LITERALend = symbol.getEnd(); 206 } 207 /** 208 * Retrieves the value for the lexeme LITERAL. 209 * @return The value for the lexeme LITERAL. 210 * @apilevel high-level 211 */ 212 @ASTNodeAnnotation.Token(name="LITERAL") 213 public String getLITERAL() { 214 return tokenString_LITERAL != null ? tokenString_LITERAL : ""; 215 } 216 /** 217 * @apilevel internal 218 */ 219 protected boolean type_computed = false; 220 /** 221 * @apilevel internal 222 */ 223 protected TypeDecl type_value; 224 /** 225 * @apilevel internal 226 */ 227 private void type_reset() { 228 type_computed = false; 229 type_value = null; 230 } 231 /** 232 * @attribute syn 233 * @aspect TypeAnalysis 234 * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:302 235 */ 236 @ASTNodeAnnotation.Attribute 237 public TypeDecl type() { 238 ASTNode$State state = state(); 239 if (type_computed) { 240 return type_value; 241 } 242 boolean intermediate = state.INTERMEDIATE_VALUE; 243 state.INTERMEDIATE_VALUE = false; 244 int num = state.boundariesCrossed; 245 boolean isFinal = this.is$Final(); 246 type_value = unknownType(); 247 if (isFinal && num == state().boundariesCrossed) { 248 type_computed = true; 249 } else { 250 } 251 state.INTERMEDIATE_VALUE |= intermediate; 252 253 return type_value; 254 } 255 /** 256 * Fetches the immediately enclosing compilation unit. 257 * @attribute inh 258 * @aspect Java7Literals 259 * @declaredat /home/jesper/git/extendj/java7/frontend/Literals.jrag:490 260 */ 261 /** 262 * Fetches the immediately enclosing compilation unit. 263 * @attribute inh 264 * @aspect Java7Literals 265 * @declaredat /home/jesper/git/extendj/java7/frontend/Literals.jrag:490 266 */ 267 @ASTNodeAnnotation.Attribute 268 public CompilationUnit compilationUnit() { 269 CompilationUnit compilationUnit_value = getParent().Define_compilationUnit(this, null); 270 271 return compilationUnit_value; 272 } 273 /** 274 * @apilevel internal 275 */ 276 public ASTNode rewriteTo() { 277 return super.rewriteTo(); 278 } 279 }