rm dup code

This commit is contained in:
Terence Parr 2013-11-21 09:52:54 -08:00
parent 4cbe197a63
commit 4a46e1a679
1 changed files with 2 additions and 11 deletions

View File

@ -53,7 +53,6 @@ import java.io.StringReader;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -217,8 +216,8 @@ public class ParseTreePatternMatcher {
public List<? extends Token> tokenize(String pattern) { public List<? extends Token> tokenize(String pattern) {
// make maps for quick look up // make maps for quick look up
Map<String, Integer> tokenNameToType = toMap(parser.getTokenNames(), 0); Map<String, Integer> tokenNameToType = Utils.toMap(parser.getTokenNames());
Map<String, Integer> ruleNameToIndex = toMap(parser.getRuleNames(), 0); Map<String, Integer> ruleNameToIndex = Utils.toMap(parser.getRuleNames());
// split pattern into chunks: sea (raw input) and islands (<ID>, <expr>) // split pattern into chunks: sea (raw input) and islands (<ID>, <expr>)
List<Chunk> chunks = split(pattern); List<Chunk> chunks = split(pattern);
@ -282,14 +281,6 @@ public class ParseTreePatternMatcher {
return tokens; return tokens;
} }
public static Map<String, Integer> toMap(String[] keys, int offset) {
Map<String, Integer> m = new HashMap<String, Integer>();
for (int i=0; i<keys.length; i++) {
m.put(keys[i], i+offset);
}
return m;
}
/** Split "<ID> = <e:expr> ;" into 4 chunks for tokenizing by tokenize() */ /** Split "<ID> = <e:expr> ;" into 4 chunks for tokenizing by tokenize() */
public List<Chunk> split(String pattern) { public List<Chunk> split(String pattern) {
int p = 0; int p = 0;