Changeset 3402 for devel-tools/trunk
- Timestamp:
- Feb 12, 2008, 10:49:25 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/core/builder/RefalASGenerator.java
r3347 r3402 43 43 public class RefalASGenerator implements ProgramVisitorWithEnv<Expr.Concatenator>, 44 44 SentenceVisitorWithEnv<Expr.Concatenator>, ExpVisitorWithEnv<Expr.Concatenator> { 45 private static final Comparable MODULE = Symbol.newWord("MODULE");46 private static final Comparable IMPORT = Symbol.newWord("IMPORT");47 private static final Comparable EXPORT = Symbol.newWord("EXPORT");48 private static final Comparable LOCAL = Symbol.newWord("LOCAL");49 private static final Comparable FUNC = Symbol.newWord("FUNC");50 private static final Comparable FUNC_Q = Symbol.newWord("FUNC?");51 private static final Comparable CONST = Symbol.newWord("CONST");52 private static final Comparable NATIVE = Symbol.newWord("NATIVE");53 private static final Comparable BRANCH = Symbol.newWord("BRANCH");54 private static final Comparable ALT = Symbol.newWord("ALT");55 private static final Comparable ALT_Q = Symbol.newWord("ALT?");56 private static final Comparable NOT = Symbol.newWord("NOT");57 private static final Comparable ITER = Symbol.newWord("ITER");58 private static final Comparable TRY = Symbol.newWord("TRY");59 private static final Comparable FORMAT = Symbol.newWord("FORMAT");60 private static final Comparable LEFT = Symbol.newWord("LEFT");61 private static final Comparable RIGHT = Symbol.newWord("RIGHT");62 private static final Comparable RESULT = Symbol.newWord("RESULT");63 private static final Comparable PAREN = Symbol.newWord("PAREN");64 private static final Comparable CALL = Symbol.newWord("CALL");65 private static final Comparable REF = Symbol.newWord("REF");66 private static final Comparable CUT = Symbol.newWord("CUT");67 private static final Comparable FENCE = Symbol.newWord("STAKE");68 private static final Comparable CUTALL = Symbol.newWord("CUTALL");69 private static final Comparable FAIL = Symbol.newWord("FAIL");70 private static final Comparable ERROR = Symbol.newWord("ERROR");45 private static final Comparable<String> MODULE = Symbol.newWord("MODULE"); 46 private static final Comparable<String> IMPORT = Symbol.newWord("IMPORT"); 47 private static final Comparable<String> EXPORT = Symbol.newWord("EXPORT"); 48 private static final Comparable<String> LOCAL = Symbol.newWord("LOCAL"); 49 private static final Comparable<String> FUNC = Symbol.newWord("FUNC"); 50 private static final Comparable<String> FUNC_Q = Symbol.newWord("FUNC?"); 51 private static final Comparable<String> CONST = Symbol.newWord("CONST"); 52 private static final Comparable<String> NATIVE = Symbol.newWord("NATIVE"); 53 private static final Comparable<String> BRANCH = Symbol.newWord("BRANCH"); 54 private static final Comparable<String> ALT = Symbol.newWord("ALT"); 55 private static final Comparable<String> ALT_Q = Symbol.newWord("ALT?"); 56 private static final Comparable<String> NOT = Symbol.newWord("NOT"); 57 private static final Comparable<String> ITER = Symbol.newWord("ITER"); 58 private static final Comparable<String> TRY = Symbol.newWord("TRY"); 59 private static final Comparable<String> FORMAT = Symbol.newWord("FORMAT"); 60 private static final Comparable<String> LEFT = Symbol.newWord("LEFT"); 61 private static final Comparable<String> RIGHT = Symbol.newWord("RIGHT"); 62 private static final Comparable<String> RESULT = Symbol.newWord("RESULT"); 63 private static final Comparable<String> PAREN = Symbol.newWord("PAREN"); 64 private static final Comparable<String> CALL = Symbol.newWord("CALL"); 65 private static final Comparable<String> REF = Symbol.newWord("REF"); 66 private static final Comparable<String> CUT = Symbol.newWord("CUT"); 67 private static final Comparable<String> FENCE = Symbol.newWord("STAKE"); 68 private static final Comparable<String> CUTALL = Symbol.newWord("CUTALL"); 69 private static final Comparable<String> FAIL = Symbol.newWord("FAIL"); 70 private static final Comparable<String> ERROR = Symbol.newWord("ERROR"); 71 71 72 72 private static Expr makeName (String name) { … … 86 86 87 87 private String moduleName; 88 88 89 89 // ProgramVisitorWithEnv<Expr.Concatenator> 90 90 … … 101 101 items.toRight(makeName(modName + "." + astConstBinding.name.identifier)); 102 102 astConstBinding.exp.accept(this, items); 103 e.toRight((Comparable ) items.yield());103 e.toRight((Comparable<Expr>) items.yield()); 104 104 } 105 105 … … 119 119 Expr.Concatenator inFormat = Expr.getConcatenator(); 120 120 astFuncDecl.inFormat.accept(this, inFormat); 121 items.toRight((Comparable ) inFormat.yield());121 items.toRight((Comparable<Expr>) inFormat.yield()); 122 122 Expr.Concatenator outFormat = Expr.getConcatenator(); 123 123 astFuncDecl.outFormat.accept(this, outFormat); 124 items.toRight((Comparable ) outFormat.yield());124 items.toRight((Comparable<Expr>) outFormat.yield()); 125 125 if (astFuncDecl.funcDef instanceof AstNative) 126 126 items.toRight(((AstNative) astFuncDecl.funcDef).right.identifier); … … 129 129 body.toRight(BRANCH); 130 130 ((AstFuncDef) astFuncDecl.funcDef).body.accept(this, body); 131 items.toRight((Comparable ) body.yield());131 items.toRight((Comparable<Expr>) body.yield()); 132 132 } 133 e.toRight((Comparable ) items.yield());133 e.toRight((Comparable<Expr>) items.yield()); 134 134 } 135 135 … … 161 161 Expr.Concatenator inFormat = Expr.getConcatenator(); 162 162 astFuncDecl.inFormat.accept(this, inFormat); 163 items.toRight((Comparable ) inFormat.yield());163 items.toRight((Comparable<Expr>) inFormat.yield()); 164 164 Expr.Concatenator outFormat = Expr.getConcatenator(); 165 165 astFuncDecl.outFormat.accept(this, outFormat); 166 items.toRight((Comparable ) outFormat.yield());166 items.toRight((Comparable<Expr>) outFormat.yield()); 167 167 items.toRight(astNative.left.identifier); 168 e.toRight((Comparable ) items.yield());168 e.toRight((Comparable<Expr>) items.yield()); 169 169 } 170 170 … … 180 180 String modName = astObjDecl.module != null ? astObjDecl.module : moduleName; 181 181 items.toRight(makeName(modName + "." + astObjDecl.name.identifier)); 182 e.toRight((Comparable ) items.yield());182 e.toRight((Comparable<Expr>) items.yield()); 183 183 } 184 184 … … 199 199 sentence.toRight(BRANCH); 200 200 astSentence.accept(this, sentence); 201 items.toRight((Comparable ) sentence.yield());201 items.toRight((Comparable<Expr>) sentence.yield()); 202 202 } 203 e.toRight((Comparable ) items.yield());203 e.toRight((Comparable<Expr>) items.yield()); 204 204 } 205 205 206 206 public void visit (AstCut astCut, Expr.Concatenator e) { 207 e.toRight((Comparable ) new Expr(CUT));207 e.toRight((Comparable<Expr>) new Expr(CUT)); 208 208 } 209 209 210 210 public void visit (AstCutAll astCutAll, Expr.Concatenator e) { 211 e.toRight((Comparable ) new Expr(CUTALL));211 e.toRight((Comparable<Expr>) new Expr(CUTALL)); 212 212 } 213 213 … … 216 216 error.toRight(ERROR); 217 217 astError.sentence.accept(this, error); 218 e.toRight((Comparable ) error.yield());218 e.toRight((Comparable<Expr>) error.yield()); 219 219 } 220 220 221 221 public void visit (AstFail astFail, Expr.Concatenator e) { 222 e.toRight((Comparable ) new Expr(FAIL));222 e.toRight((Comparable<Expr>) new Expr(FAIL)); 223 223 } 224 224 225 225 public void visit (AstFence astFence, Expr.Concatenator e) { 226 e.toRight((Comparable ) new Expr(FENCE));226 e.toRight((Comparable<Expr>) new Expr(FENCE)); 227 227 } 228 228 … … 231 231 format.toRight(FORMAT); 232 232 astFormat.exp.accept(this, format); 233 e.toRight((Comparable ) format.yield());233 e.toRight((Comparable<Expr>) format.yield()); 234 234 } 235 235 … … 240 240 source.toRight(BRANCH); 241 241 astIter.sentence.accept(this, source); 242 iter.toRight((Comparable ) source.yield());242 iter.toRight((Comparable<Expr>) source.yield()); 243 243 Expr.Concatenator format = Expr.getConcatenator(); 244 244 format.toRight(FORMAT); 245 245 astIter.target.accept(this, format); 246 iter.toRight((Comparable ) format.yield());247 e.toRight((Comparable ) iter.yield());246 iter.toRight((Comparable<Expr>) format.yield()); 247 e.toRight((Comparable<Expr>) iter.yield()); 248 248 } 249 249 250 250 public void visit (AstNot astNot, Expr.Concatenator e) { 251 Comparable[] items = new Comparable[2];252 items[0] = NOT;253 251 Expr.Concatenator source = Expr.getConcatenator(); 254 252 source.toRight(BRANCH); 255 253 astNot.sentence.accept(this, source); 256 items[1] = source.yield(); 257 e.toRight((Comparable) Expr.concat(items[0], items[1])); 254 e.toRight((Comparable<Expr>) Expr.concat(NOT, (Comparable<Expr>) source.yield())); 258 255 } 259 256 … … 262 259 items.toRight(astPattern.dir.select(LEFT, RIGHT)); 263 260 astPattern.exp.accept(this, items); 264 e.toRight((Comparable ) items.yield());261 e.toRight((Comparable<Expr>) items.yield()); 265 262 } 266 263 … … 269 266 items.toRight(RESULT); 270 267 astResult.exp.accept(this, items); 271 e.toRight((Comparable ) items.yield());268 e.toRight((Comparable<Expr>) items.yield()); 272 269 } 273 270 … … 283 280 trap.toRight(BRANCH); 284 281 astTrap.trySentence.accept(this, trap); 285 items.toRight((Comparable ) trap.yield());282 items.toRight((Comparable<Expr>) trap.yield()); 286 283 Expr.Concatenator with = Expr.getConcatenator(); 287 284 with.toRight(BRANCH); 288 285 astTrap.catchSentence.accept(this, with); 289 items.toRight((Comparable ) with.yield());290 e.toRight((Comparable ) items.yield());286 items.toRight((Comparable<Expr>) with.yield()); 287 e.toRight((Comparable<Expr>) items.yield()); 291 288 } 292 289 … … 301 298 items.toRight(makeName(modName + "." + astCall.funcDecl.name.identifier)); 302 299 astCall.arg.accept(this, items); 303 e.toRight((Comparable ) items.yield());300 e.toRight((Comparable<Expr>) items.yield()); 304 301 } 305 302 … … 321 318 items.toRight(PAREN); 322 319 astParen.exp.accept(this, items); 323 e.toRight((Comparable ) items.yield());320 e.toRight((Comparable<Expr>) items.yield()); 324 321 } 325 322 … … 331 328 modName = moduleName; 332 329 items.toRight(makeName(modName + "." + astRef.decl.name.identifier)); 333 e.toRight((Comparable ) items.yield());330 e.toRight((Comparable<Expr>) items.yield()); 334 331 } 335 332 336 333 public void visit (AstVar astVar, Expr.Concatenator e) { 337 Comparable [] items = new Comparable[2];338 items[0] = Symbol.newWord(astVar.type.name() + "VAR");334 Comparable<String> symbol1 = Symbol.newWord(astVar.type.name() + "VAR"); 335 Comparable<Expr> symbol2; 339 336 if (astVar.name != null && astVar.name.identifier.length() > 0) 340 items[1]= new Expr(Symbol.newWord(astVar.name.identifier));337 symbol2 = new Expr(Symbol.newWord(astVar.name.identifier)); 341 338 else 342 items[1]= new Expr(Symbol.newWord("$tmp-" + astVar.pos.charStart));343 e.toRight((Comparable ) Expr.concat(items[0], items[1]));339 symbol2 = new Expr(Symbol.newWord("$tmp-" + astVar.pos.charStart)); 340 e.toRight((Comparable<Expr>) Expr.concat(symbol1, symbol2)); 344 341 } 345 342
Note: See TracChangeset
for help on using the changeset viewer.