1 19 20 package ca.mcgill.sable.soot.editors; 21 22 import java.util.*; 23 import org.eclipse.jface.text.rules.*; 24 import org.eclipse.jface.text.*; 25 26 public class JimpleScanner extends RuleBasedScanner { 27 28 private static String [] keywords= { 29 "ignored", 30 "abstract", 31 "final", 32 "native", 33 "public", 34 "protected", 35 "private", 36 "static", 37 "synchronized", 38 "transient", 39 "volatile", 40 "class", 41 "interface", 42 "void", 43 "boolean", 44 "byte", 45 "short", 46 "char", 47 "int", 48 "long", 49 "float", 50 "double", 51 "null_type", 52 "unknown", 53 "extends", 54 "implements", 55 "breakpoint", 56 "case", 57 "catch", 58 "cmp", 59 "cmpg", 60 "cmpl", 61 "default", 62 "entermonitor", 63 "exitmonitor", 64 "goto", 65 "if", 66 "instanceof", 67 "interfaceinvoke", 68 "lengthof", 69 "lookupswitch", 70 "neg", 71 "new", 72 "newarray", 73 "newmultiarray", 74 "nop", 75 "ret", 76 "return", 77 "specialinvoke", 78 "staticinvoke", 79 "tableswitch", 80 "throw", 81 "throws", 82 "virtualinvoke", 83 "null", 84 "from", 85 "to", 86 "with" 87 }; 88 89 90 public JimpleScanner(ColorManager manager) { 91 92 List rules = new ArrayList(); 93 94 IToken string = new Token(new TextAttribute(manager.getColor(IJimpleColorConstants.JIMPLE_STRING))); 95 IToken def= new Token(new TextAttribute(manager.getColor(IJimpleColorConstants.JIMPLE_DEFAULT))); 96 IToken key= new Token(new TextAttribute(manager.getColor(IJimpleColorConstants.JIMPLE_KEYWORD))); 97 98 rules.add(new SingleLineRule("\"", "\"", string, '\\')); 99 rules.add(new SingleLineRule("'", "'", string, '\\')); 100 101 WordRule wordRule= new WordRule(new JimpleWordDetector(), def); 102 103 104 for (int i=0; i<keywords.length; i++) 105 wordRule.addWord(keywords[i], key); 106 107 rules.add(wordRule); 108 109 110 rules.add(new WhitespaceRule(new JimpleWhitespaceDetector())); 112 113 IRule[] result = new IRule[rules.size()]; 114 rules.toArray(result); 115 setRules(result); 116 } 117 } 118 | Popular Tags |