1 21 22 package org.armedbear.j; 23 24 import gnu.regexp.RE; 25 import gnu.regexp.REMatch; 26 import gnu.regexp.UncheckedRE; 27 import java.util.ArrayList ; 28 29 public final class VerilogTagger extends Tagger 30 { 31 private static final RE moduleRE = 34 new UncheckedRE("^module\\s+([a-zA-Z_][a-zA-Z0-9_$]*)"); 35 private static final RE primitiveRE = 36 new UncheckedRE("^primitive\\s+([a-zA-Z_][a-zA-Z0-9_$]*)"); 37 38 public VerilogTagger(SystemBuffer buffer) 39 { 40 super(buffer); 41 } 42 43 public void run() 44 { 45 ArrayList tags = new ArrayList (); 46 Line line = buffer.getFirstLine(); 47 while (line != null) { 48 String s = line.trim(); 49 if (s != null) { 50 REMatch match; 51 if (s.startsWith("module")) 52 match = moduleRE.getMatch(s); 53 else if (s.startsWith("primitive")) 54 match = primitiveRE.getMatch(s); 55 else 56 match = null; 57 if (match != null) { 58 String name = s.substring(match.getSubStartIndex(1), 59 match.getSubEndIndex(1)); 60 tags.add(new LocalTag(name, line)); 61 } 62 } 63 line = line.next(); 64 } 65 buffer.setTags(tags); 66 } 67 } 68 | Popular Tags |