1 21 22 package org.armedbear.j; 23 24 public final class VHDLSyntaxIterator extends DefaultSyntaxIterator 27 { 28 private static final int STATE_NEUTRAL = 0; 29 private static final int STATE_DOUBLEQUOTE = 1; 30 31 public VHDLSyntaxIterator(Position pos) 32 { 33 super(pos); 34 } 35 36 public char[] hideSyntacticWhitespace(Line line) 37 { 38 return hideSyntacticWhitespace(line.getText()); 39 } 40 41 public char[] hideSyntacticWhitespace(String s) 44 { 45 final char[] chars = s.toCharArray(); 46 int state = STATE_NEUTRAL; 47 final int length = chars.length; 48 for (int i = 0; i < length; i++) { 49 char c = chars[i]; 50 if (c == '\\' && i < length-1) { 51 chars[i++] = ' '; 53 chars[i] = ' '; 54 continue; 55 } 56 if (state == STATE_DOUBLEQUOTE) { 57 chars[i] = ' '; 58 if (c == '"') 59 state = STATE_NEUTRAL; 60 continue; 61 } 62 if (c == '"') { 64 chars[i] = ' '; 65 state = STATE_DOUBLEQUOTE; 66 continue; 67 } 68 if (c == '-') { 69 if (i < length-1) { 70 if (chars[i+1] == '-') { 71 for (int j = i; j < length; j++) 73 chars[j] = ' '; 74 return chars; 75 } 76 } 77 } 78 } 79 return chars; 80 } 81 } 82 | Popular Tags |