code: public static Token parse(final String pattern) {
  		List<Token> tokens = new ArrayList<Token>();
  
  		int start = 0;
  		int count = 0;
  
  		for (int i = 0; i < pattern.length(); ++i) {
  			char character = pattern.charAt(i);
  
  			if (character == '{') {
  				if (count == 0) {
  					if (start < i) {
  						tokens.add(new PlainTextToken(pattern.substring(start, i)));
  					}
  					start = i;
  				}
  				count += 1;
  			} else if (character == '}') {
  				if (count == 0) {
  					InternalLogger.log(Level.ERROR, "Opening curly bracket is missing: '" + pattern + "'");
  				} else {
  					count -= 1;
  					if (count == 0) {
  						tokens.add(parse(pattern.substring(start + 1, i)));
  						start = i + 1;
  					}
  				}
  			}
  		}
  
  		if (count > 0) {
  			InternalLogger.log(Level.ERROR, "Closing curly bracket is missing: '" + pattern + "'");
  		}
  
  		int splitIndex = pattern.indexOf('|', start);
  		if (splitIndex == -1) {
  			tokens.add(createPlainToken(pattern.substring(start)));
  			return tokens.size() == 1 ? tokens.get(0) : new BundleToken(tokens);
  		} else {
  			String token = pattern.substring(start, splitIndex).trim();
  			tokens.add(createPlainToken(token));
  			String[] styleOptions = SPLIT_PATTERN.split(pattern.substring(splitIndex + 1));
  			return styleToken(tokens.size() == 1 ? tokens.get(0) : new BundleToken(tokens), styleOptions);
  		}
  	}
docs: Parses a format pattern and produces a generic token from it. This token can be used by writers for rendering log
  entries.
  
  @param pattern
  Format pattern
  @return Produced root token