jodd-db/src/main/java/jodd/db/oom/sqlgen/TemplateParser.java
public void parse(final DbSqlBuilder sqlBuilder, final String template) {
		int length = template.length();
		int last = 0;
		while (true) {
			int mark = template.indexOf('$', last);
			if (mark == -1) {
				if (last < length) {
					sqlBuilder.appendRaw(template.substring(last));
				}
				break;
			}

			int escapesCount = countEscapes(template, mark);                // check if escaped
			if (escapesCount > 0) {
				boolean isEscaped = escapesCount % 2 != 0;
				int escapesToAdd = escapesCount >> 1;
				sqlBuilder.appendRaw(template.substring(last, mark - escapesCount + escapesToAdd) + '$');
				if (isEscaped) {
					last = mark + 1;
					continue;
				}
			} else {
				sqlBuilder.appendRaw(template.substring(last, mark));
			}

			int end;

			if (template.startsWith(MACRO_TABLE, mark)) {
				mark += MACRO_TABLE.length();
				end = findMacroEnd(template, mark);
				onTable(sqlBuilder, template.substring(mark, end));
			} else if (template.startsWith(MACRO_COLUMN, mark)) {
				mark += MACRO_COLUMN.length();
				end = findMacroEnd(template, mark);
				onColumn(sqlBuilder, template.substring(mark, end));
			} else if (template.startsWith(MACRO_MATCH, mark)) {
				mark += MACRO_MATCH.length();
				end = findMacroEnd(template, mark);
				onMatch(sqlBuilder, template.substring(mark, end));
			} else if (template.startsWith(MACRO_VALUE, mark)) {
				mark += MACRO_VALUE.length();
				end = findMacroEnd(template, mark);
				onValue(sqlBuilder, template.substring(mark, end));
			} else {
				mark++;           // reference found
				end = mark;       // find macro end
				while (end < length) {
					if (!isReferenceChar(template, end)) {
						break;
					}
					end++;
				}
				onReference(sqlBuilder, template.substring(mark, end));
				end--;
			}
			end++;
			last = end;
		}
	}
public void parse(final DbSqlBuilder sqlBuilder, final String template) {
		int length = template.length();
		int last = 0;
		while (true) {
			int mark = template.indexOf('$', last);
			if (mark == -1) {
				if (last < length) {
					sqlBuilder.appendRaw(template.substring(last));
				}
				break;
			}

			int escapesCount = countEscapes(template, mark);                // check if escaped
			if (escapesCount > 0) {
				boolean isEscaped = escapesCount % 2 != 0;
				int escapesToAdd = escapesCount >> 1;
				sqlBuilder.appendRaw(template.substring(last, mark - escapesCount + escapesToAdd) + '$');
				if (isEscaped) {
					last = mark + 1;
					continue;
				}
			} else {
				sqlBuilder.appendRaw(template.substring(last, mark));
			}

			int end;

			if (template.startsWith(MACRO_TABLE, mark)) {
				mark += MACRO_TABLE.length();
				end = findMacroEnd(template, mark);
				onTable(sqlBuilder, template.substring(mark, end));
			} else if (template.startsWith(MACRO_COLUMN, mark)) {
				mark += MACRO_COLUMN.length();
				end = findMacroEnd(template, mark);
				onColumn(sqlBuilder, template.substring(mark, end));
			} else if (template.startsWith(MACRO_MATCH, mark)) {
				mark += MACRO_MATCH.length();
				end = findMacroEnd(template, mark);
				onMatch(sqlBuilder, template.substring(mark, end));
			} else if (template.startsWith(MACRO_VALUE, mark)) {
				mark += MACRO_VALUE.length();
				end = findMacroEnd(template, mark);
				onValue(sqlBuilder, template.substring(mark, end));
			} else {
				mark++;           // reference found
				end = mark;       // find macro end
				while (end < length) {
					if (!isReferenceChar(template, end)) {
						break;
					}
					end++;
				}
				onReference(sqlBuilder, template.substring(mark, end));
				end--;
			}
			end++;
			last = end;
		}
	}
Parses template and returns generated sql builder.