- Common ways to obtain Token
private void myMethod () {}
public static Token parse(final CharSequence s, final int index) { Character lastQuote = null; int pos = index; while (pos < s.length()) { char c = s.charAt(pos); if (lastQuote == null) { if (c == '|') { break; } else if (c == '"' || c == '\'') { lastQuote = c; } } else { if (lastQuote == c) { lastQuote = null; } } pos++; } Token next = pos < s.length() ? parse(s, pos + 1) : null; return new Token(s.subSequence(index, pos).toString(), next); } }
public static Token parse(final CharSequence s, final int index) { Character lastQuote = null; int pos = index; while (pos < s.length()) { char c = s.charAt(pos); if (lastQuote == null) { if (c == '|') { break; } else if (c == '"' || c == '\'') { lastQuote = c; } } else { if (lastQuote == c) { lastQuote = null; } } pos++; } Token next = pos < s.length() ? parse(s, pos + 1) : null; return new Token(s.subSequence(index, pos).toString(), next); } }
public static Token parse(final CharSequence s, final int index) { Character lastQuote = null; int pos = index; while (pos < s.length()) { char c = s.charAt(pos); if (lastQuote == null) { if (c == '|') { break; } else if (c == '"' || c == '\'') { lastQuote = c; } } else { if (lastQuote == c) { lastQuote = null; } } pos++; } Token next = pos < s.length() ? parse(s, pos + 1) : null; return new Token(s.subSequence(index, pos).toString(), next); } }