| 84 | } |
| 85 | |
| 86 | fn find_casing_parameter(tokens: &[tokens::Token], parameter: String) -> Option<Casing> { |
| 87 | let upcase = tokens.windows(3).any(|window| { |
| 88 | matches!( |
| 89 | window, |
| 90 | [ |
| 91 | tokens::Token::Parameter(param), |
| 92 | tokens::Token::Equal, |
| 93 | tokens::Token::True, |
| 94 | ] if *param == parameter |
| 95 | ) |
| 96 | }); |
| 97 | |
| 98 | let downcase = tokens.windows(3).any(|window| { |
| 99 | matches!( |
| 100 | window, |
| 101 | [ |
| 102 | tokens::Token::Parameter(param), |
| 103 | tokens::Token::Equal, |
| 104 | tokens::Token::False, |
| 105 | ] if *param == parameter |
| 106 | ) |
| 107 | }); |
| 108 | |
| 109 | if upcase && !downcase { |
| 110 | return Some(Casing::Upcase); |
| 111 | } |
| 112 | |
| 113 | if downcase && !upcase { |
| 114 | return Some(Casing::Downcase); |
| 115 | } |
| 116 | |
| 117 | return None; |
| 118 | } |
| 119 | |
| 120 | // TODO: define a `consume` function to not keep repeating the peeks_tokens.next() all the time |
| 121 | pub fn parse(tokens: Vec<tokens::Token>) -> Vec<Function> { |