Changeset 202
- Timestamp:
- 11/05/02 02:24:53 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/j/CTagger.java
r200 r202 3 3 * 4 4 * Copyright (C) 1998-2002 Peter Graves 5 * $Id: CTagger.java,v 1. 3 2002-11-05 01:25:52piso Exp $5 * $Id: CTagger.java,v 1.4 2002-11-05 02:24:53 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 112 112 } 113 113 if (isIdentifierStart(c)) { 114 String s = gatherToken(); 114 tokenStart = pos.copy(); 115 String s = gatherToken(pos); 115 116 if (s.startsWith("ARGS") && lynxArgsMacroRE.isMatch(s)) { 116 117 // Lynx "ARGSnn" macro. … … 119 120 // Lynx macro. 120 121 state = METHOD_NAME; 121 } else if ( s.equals("DEFUN")) {122 } else if (isDefunStart(s)) { 122 123 // Emacs macro. 123 while (!isIdentifierStart(c = pos.getChar())) { 124 while (true) { 125 c = pos.getChar(); 126 if (c == '"') { 127 pos.next(); 128 break; 129 } 124 130 if (!pos.next()) 125 131 break; 126 132 } 127 gatherDefunName(); 133 tokenStart = pos.copy(); 134 token = gatherDefunName(pos); 128 135 tags.add(new CTag(token, tokenStart)); 129 136 while ((c = pos.getChar()) != '{') { … … 133 140 if (c == '{') 134 141 skipBrace(); 135 } else { 136 tokenStart = new Position(pos.getLine(), pos.getOffset() - s.length()); 142 } else 137 143 token = s; 138 }139 144 continue; 140 145 } … … 149 154 } 150 155 151 private String gatherToken( )156 private String gatherToken(Position pos) 152 157 { 153 158 FastStringBuffer sb = new FastStringBuffer(); … … 160 165 return sb.toString(); 161 166 } 162 163 private void gatherDefunName() 164 { 165 tokenStart = new Position(pos); 167 168 private static boolean isDefunStart(String s) 169 { 170 if (s.length() < 5) 171 return false; 172 if (s.charAt(0) != 'D') 173 return false; 174 if (s.equals("DEFUN")) // Emacs, rep 175 return true; 176 if (s.equals("DEFUN_INT")) // rep 177 return true; 178 return false; 179 } 180 181 private static String gatherDefunName(Position pos) 182 { 166 183 FastStringBuffer sb = new FastStringBuffer(); 167 184 char c; 168 while ((c = pos.getChar()) != '"' ) {185 while ((c = pos.getChar()) != '"' && c != EOL) { 169 186 sb.append(c); 170 187 if (!pos.next()) 171 188 break; 172 189 } 173 token =sb.toString();190 return sb.toString(); 174 191 } 175 192
Note: See TracChangeset
for help on using the changeset viewer.