aboutsummaryrefslogtreecommitdiffstats
path: root/askama_parser/src/lib.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-02 11:20:35 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2023-07-31 10:27:15 +0200
commit2376cc6815a83aec7b0b76a671fabe4c22441aea (patch)
tree665ab6505ca32220cd0abaf6ca3e32c87447cf61 /askama_parser/src/lib.rs
parent1677fd6f57bcbfe1c810b3839bf155b3a0a02b76 (diff)
downloadaskama-2376cc6815a83aec7b0b76a671fabe4c22441aea.tar.gz
askama-2376cc6815a83aec7b0b76a671fabe4c22441aea.tar.bz2
askama-2376cc6815a83aec7b0b76a671fabe4c22441aea.zip
parser: move nested_parenthesis() helper into node module
Diffstat (limited to 'askama_parser/src/lib.rs')
-rw-r--r--askama_parser/src/lib.rs48
1 files changed, 0 insertions, 48 deletions
diff --git a/askama_parser/src/lib.rs b/askama_parser/src/lib.rs
index ac4ebb7..970fb2e 100644
--- a/askama_parser/src/lib.rs
+++ b/askama_parser/src/lib.rs
@@ -202,54 +202,6 @@ fn char_lit(i: &str) -> IResult<&str, &str> {
Ok((i, s.unwrap_or_default()))
}
-fn nested_parenthesis(i: &str) -> IResult<&str, ()> {
- let mut nested = 0;
- let mut last = 0;
- let mut in_str = false;
- let mut escaped = false;
-
- for (i, b) in i.chars().enumerate() {
- if !(b == '(' || b == ')') || !in_str {
- match b {
- '(' => nested += 1,
- ')' => {
- if nested == 0 {
- last = i;
- break;
- }
- nested -= 1;
- }
- '"' => {
- if in_str {
- if !escaped {
- in_str = false;
- }
- } else {
- in_str = true;
- }
- }
- '\\' => {
- escaped = !escaped;
- }
- _ => (),
- }
- }
-
- if escaped && b != '\\' {
- escaped = false;
- }
- }
-
- if nested == 0 {
- Ok((&i[last..], ()))
- } else {
- Err(nom::Err::Error(error_position!(
- i,
- ErrorKind::SeparatedNonEmptyList
- )))
- }
-}
-
fn path(i: &str) -> IResult<&str, Vec<&str>> {
let root = opt(value("", ws(tag("::"))));
let tail = separated_list1(ws(tag("::")), identifier);