Hayır, bunu ayrıştırmak için bir bağlam serbest dilbilgisi (veya Perl özyinelemeli İfadelerinin) yazmalısınız. Ne ihmal iç içe şablonları değiştirilir?
Ayrıştırıcı pseudocode bu gibi görünecektir:
input = "| {{ | {{ | }} | | }} |", pointer = 0;
char = '', results = [];
read_next_char() {
return input[++ pointer];
}
go_back_one_char() {
pointer --;
}
while (char = read_next_char()) {
if (char == '{') {
if (read_next_char() == '{') InsideBraces();
else go_back_one_char();
}
}
InsideBraces(skipping=false) {
result = "";
while (char = read_next_char()) {
if (char == '{') {
if (read_next_char() == '}') InsideBraces();
else go_back_one_char();
} else if (char == '}') {
if (read_next_char() == '}') break;
else go_back_one_char();
} else {
result += char;
}
}
if (!skipping) results.push(result);
}