diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2017-04-05 15:35:13 -0400 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2017-04-05 15:35:13 -0400 |
| commit | c82452e59b1547392c3e89d08d9173cc6dc79e23 (patch) | |
| tree | 1927051f7cab7a64eef3f53a78b77780db6cf281 /JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens | |
| parent | b61c66d5e0c18faee68eb91881d5dfe760818856 (diff) | |
Reorganize
Diffstat (limited to 'JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens')
| -rw-r--r-- | JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens/StringToken.java | 84 | ||||
| -rw-r--r-- | JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens/StringTokenStream.java | 56 |
2 files changed, 0 insertions, 140 deletions
diff --git a/JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens/StringToken.java b/JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens/StringToken.java deleted file mode 100644 index f156f02..0000000 --- a/JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens/StringToken.java +++ /dev/null @@ -1,84 +0,0 @@ -package bjc.utils.parserutils.pratt.tokens; - -import bjc.utils.parserutils.pratt.Token; - -/** - * Simple token implementation for strings. - * - * @author EVE - * - */ -public class StringToken implements Token<String, String> { - private String key; - private String val; - - /** - * Create a new string token. - * - * @param ky - * The key for the token. - * - * @param vl - * The value for the token. - */ - public StringToken(String ky, String vl) { - key = ky; - val = vl; - } - - @Override - public String getKey() { - return key; - } - - @Override - public String getValue() { - return val; - } - - @Override - public int hashCode() { - final int prime = 31; - - int result = 1; - result = prime * result + ((key == null) ? 0 : key.hashCode()); - result = prime * result + ((val == null) ? 0 : val.hashCode()); - - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof StringToken)) - return false; - - StringToken other = (StringToken) obj; - - if (key == null) { - if (other.key != null) - return false; - } else if (!key.equals(other.key)) - return false; - - if (val == null) { - if (other.val != null) - return false; - } else if (!val.equals(other.val)) - return false; - - return true; - } - - @Override - public String toString() { - return String.format("StringToken [key='%s', val='%s']", key, val); - } - - public static StringToken litToken(String val) { - return new StringToken(val, val); - } -} diff --git a/JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens/StringTokenStream.java b/JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens/StringTokenStream.java deleted file mode 100644 index 75e86c4..0000000 --- a/JPratt/src/main/java/bjc/utils/parserutils/pratt/tokens/StringTokenStream.java +++ /dev/null @@ -1,56 +0,0 @@ -package bjc.utils.parserutils.pratt.tokens; - -import java.util.Iterator; - -import bjc.utils.parserutils.pratt.Token; -import bjc.utils.parserutils.pratt.TokenStream; - -import static bjc.utils.parserutils.pratt.tokens.StringToken.litToken; - -/** - * Simple implementation of token stream for strings. - * - * The terminal token here is represented by a token with type and value - * '(end)'. - * - * @author EVE - * - */ -public class StringTokenStream extends TokenStream<String, String> { - private Iterator<Token<String, String>> iter; - - private Token<String, String> curr; - - /** - * Create a new token stream from a iterator. - * - * @param itr - * The iterator to use. - * - */ - public StringTokenStream(Iterator<Token<String, String>> itr) { - iter = itr; - - } - - @Override - public Token<String, String> current() { - return curr; - } - - @Override - public Token<String, String> next() { - if (iter.hasNext()) { - curr = iter.next(); - } else { - curr = litToken("(end)"); - } - - return curr; - } - - @Override - public boolean hasNext() { - return iter.hasNext(); - } -} |
