1 33 34 package edu.rice.cs.drjava.model.definitions.reducedmodel; 35 36 44 public abstract class ReducedModelState implements ReducedModelStates { 45 46 abstract ReducedModelState update(TokenList.Iterator copyCursor); 47 48 56 boolean _combineCurrentAndNextIfFind(String first, String second, TokenList.Iterator copyCursor) { 57 if (copyCursor.atStart() || copyCursor.atEnd() || copyCursor.atLastItem() || 58 !copyCursor.current().getType().equals(first)) 59 return false; 60 61 copyCursor.next(); 63 if (copyCursor.current().getType().equals(second)) { 66 if (copyCursor.current().getType().equals("") && copyCursor.prevItem().getType().equals("")) { 67 copyCursor.prev(); 69 int growth = copyCursor.current().getSize(); 70 copyCursor.remove(); 71 copyCursor.current().grow(growth); 72 } 73 else if (copyCursor.current().getType().length() == 2) { 74 String tail = copyCursor.current().getType().substring(1,2); 75 String head = copyCursor.prevItem().getType() + 76 copyCursor.current().getType().substring(0,1); 77 copyCursor.current().setType(tail); 78 copyCursor.prev(); 79 copyCursor.current().setType(head); 80 copyCursor.current().setState(FREE); 81 } 82 else { 83 copyCursor.prev(); 85 copyCursor.remove(); 86 copyCursor.current().setType(first + second); 87 } 88 return true; 89 } 90 else { 91 copyCursor.prev(); 93 return false; 94 } 95 } 96 97 boolean _combineCurrentAndNextIfEscape(TokenList.Iterator copyCursor) { 98 boolean combined = _combineCurrentAndNextIfFind("\\","\\",copyCursor); combined = combined || _combineCurrentAndNextIfFind("\\","\'",copyCursor); combined = combined || _combineCurrentAndNextIfFind("\\","\\'",copyCursor); combined = combined || _combineCurrentAndNextIfFind("\\","\"",copyCursor); combined = combined || _combineCurrentAndNextIfFind("\\","\\\"",copyCursor); combined = combined || _combineCurrentAndNextIfFind("\\","\\\\",copyCursor); return combined; 105 } 106 } 107 | Popular Tags |