MCPcopy Create free account
hub / github.com/cherryramatisdev/regexer / find_casing_parameter

Function find_casing_parameter

regexer/src/lexer/ast.rs:86–118  ·  view source on GitHub ↗
(tokens: &[tokens::Token], parameter: String)

Source from the content-addressed store, hash-verified

84}
85
86fn 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
121pub fn parse(tokens: Vec<tokens::Token>) -> Vec<Function> {

Callers 1

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected