001 /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */ 002 package AST; 003 004 import java.util.HashSet; 005 import java.io.File; 006 import java.util.*; 007 import beaver.*; 008 import java.util.ArrayList; 009 import java.util.zip.*; 010 import java.io.*; 011 import java.io.FileNotFoundException; 012 import java.util.Collection; 013 /** 014 * Literal produced when the compiler tries to parse 015 * a malformatted NumericLiteral. 016 * This literal kind has an associated error message. 017 * @production IllegalLiteral : {@link Literal}; 018 * @ast node 019 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/Literals.ast:11 020 */ 021 public class IllegalLiteral extends Literal implements Cloneable { 022 /** 023 * @apilevel low-level 024 */ 025 public void flushCache() { 026 } 027 /** 028 * @apilevel internal 029 */ 030 public void flushCollectionCache() { 031 } 032 /** 033 * @apilevel internal 034 */ 035 @SuppressWarnings({"unchecked", "cast"}) 036 public IllegalLiteral clone() throws CloneNotSupportedException { 037 IllegalLiteral node = (IllegalLiteral)super.clone(); 038 node.type_computed = false; 039 node.type_value = null; 040 node.in$Circle(false); 041 node.is$Final(false); 042 return node; 043 } 044 /** 045 * @apilevel internal 046 */ 047 @SuppressWarnings({"unchecked", "cast"}) 048 public IllegalLiteral copy() { 049 050 try { 051 IllegalLiteral node = (IllegalLiteral) clone(); 052 node.parent = null; 053 if(children != null) 054 node.children = (ASTNode[]) children.clone(); 055 056 return node; 057 } catch (CloneNotSupportedException e) { 058 throw new Error("Error: clone not supported for " + getClass().getName()); 059 } 060 061 }/** 062 * Create a deep copy of the AST subtree at this node. 063 * The copy is dangling, i.e. has no parent. 064 * @return dangling copy of the subtree at this node 065 * @apilevel low-level 066 */ 067 @SuppressWarnings({"unchecked", "cast"}) 068 public IllegalLiteral fullCopy() { 069 070 IllegalLiteral tree = (IllegalLiteral) copy(); 071 if (children != null) { 072 for (int i = 0; i < children.length; ++i) { 073 074 ASTNode child = (ASTNode) children[i]; 075 if(child != null) { 076 child = child.fullCopy(); 077 tree.setChild(child, i); 078 } 079 } 080 } 081 return tree; 082 083 } /** 084 * Error processing for literals. 085 * Include the token range from parsing. 086 * @ast method 087 * @aspect Literals 088 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/Literals.jrag:469 089 */ 090 public void collectErrors() { 091 int line = getLine(LITERALstart); 092 int column = getColumn(LITERALstart); 093 int endLine = getLine(LITERALend); 094 int endColumn = getColumn(LITERALend); 095 compilationUnit().errors.add(new Problem(sourceFile(), 096 getLITERAL(), line, column, endLine, endColumn, 097 Problem.Severity.ERROR, Problem.Kind.LEXICAL)); 098 } 099 /** 100 * @ast method 101 * 102 */ 103 public IllegalLiteral() { 104 super(); 105 106 107 } 108 /** 109 * Initializes the child array to the correct size. 110 * Initializes List and Opt nta children. 111 * @apilevel internal 112 * @ast method 113 * @ast method 114 * 115 */ 116 public void init$Children() { 117 } 118 /** 119 * @ast method 120 * 121 */ 122 public IllegalLiteral(String p0) { 123 setLITERAL(p0); 124 } 125 /** 126 * @ast method 127 * 128 */ 129 public IllegalLiteral(beaver.Symbol p0) { 130 setLITERAL(p0); 131 } 132 /** 133 * @apilevel low-level 134 * @ast method 135 * 136 */ 137 protected int numChildren() { 138 return 0; 139 } 140 /** 141 * @apilevel internal 142 * @ast method 143 * 144 */ 145 public boolean mayHaveRewrite() { 146 return false; 147 } 148 /** 149 * Replaces the lexeme LITERAL. 150 * @param value The new value for the lexeme LITERAL. 151 * @apilevel high-level 152 * @ast method 153 * 154 */ 155 public void setLITERAL(String value) { 156 tokenString_LITERAL = value; 157 } 158 /** 159 * JastAdd-internal setter for lexeme LITERAL using the Beaver parser. 160 * @apilevel internal 161 * @ast method 162 * 163 */ 164 public void setLITERAL(beaver.Symbol symbol) { 165 if(symbol.value != null && !(symbol.value instanceof String)) 166 throw new UnsupportedOperationException("setLITERAL is only valid for String lexemes"); 167 tokenString_LITERAL = (String)symbol.value; 168 LITERALstart = symbol.getStart(); 169 LITERALend = symbol.getEnd(); 170 } 171 /** 172 * Retrieves the value for the lexeme LITERAL. 173 * @return The value for the lexeme LITERAL. 174 * @apilevel high-level 175 * @ast method 176 * 177 */ 178 public String getLITERAL() { 179 return tokenString_LITERAL != null ? tokenString_LITERAL : ""; 180 } 181 /** 182 * @apilevel internal 183 */ 184 protected boolean type_computed = false; 185 /** 186 * @apilevel internal 187 */ 188 protected TypeDecl type_value; 189 /** 190 * The type of an IllegalLiteral does not matter, 191 * as it is only a placeholder literal for error messages. 192 * @attribute syn 193 * @aspect Literals 194 * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/Literals.jrag:457 195 */ 196 @SuppressWarnings({"unchecked", "cast"}) 197 public TypeDecl type() { 198 if(type_computed) { 199 return type_value; 200 } 201 ASTNode$State state = state(); 202 int num = state.boundariesCrossed; 203 boolean isFinal = this.is$Final(); 204 type_value = type_compute(); 205 if(isFinal && num == state().boundariesCrossed){ type_computed = true; } 206 return type_value; 207 } 208 /** 209 * @apilevel internal 210 */ 211 private TypeDecl type_compute() { return unknownType(); } 212 /** 213 * @apilevel internal 214 */ 215 public ASTNode rewriteTo() { 216 return super.rewriteTo(); 217 } 218 }