List<Token> tokenize() throws ScanException {
    List<Token> tokenList = new ArrayList<Token>();
    StringBuilder buf = new StringBuilder();

    while (pointer < patternLength) {
      char c = pattern.charAt(pointer);
      pointer++;

      switch (state) {
        case LITERAL_STATE:
          handleLiteralState(c, tokenList, buf);
          break;
        case START_STATE:
          handleStartState(c, tokenList, buf);
          break;
        case DEFAULT_VAL_STATE:
          handleDefaultValueState(c, tokenList, buf);
        default:
      }
    }
    // EOS
    switch (state) {
      case LITERAL_STATE:
        addLiteralToken(tokenList, buf);
        break;
      case DEFAULT_VAL_STATE:
        // trailing colon. see also LOGBACK-1140
        buf.append(CoreConstants.COLON_CHAR);
        addLiteralToken(tokenList, buf);
        break;
      case START_STATE:
        // trailing $. see also LOGBACK-1149
        buf.append(CoreConstants.DOLLAR);
        addLiteralToken(tokenList, buf);
        break;
    }
    return tokenList;
  }
@Test
  public void literalEndingWithColon_LOGBACK_1140() throws ScanException {
    String input = "a:";
    Tokenizer tokenizer = new Tokenizer(input);
    List<Token> tokenList = tokenizer.tokenize();
    witnessList.add(new Token(Token.Type.LITERAL, "a"));
    witnessList.add(new Token(Token.Type.LITERAL, ":"));
    assertEquals(witnessList, tokenList);
  }