MCPcopy Index your code
hub / github.com/AI45Lab/Code / parse_bare_token

Method parse_bare_token

core/src/tools/builtin/bash.rs:950–970  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

948 }
949
950 fn parse_bare_token(&mut self) -> Option<String> {
951 let start = self.pos;
952 while let Some(ch) = self.peek() {
953 if ch == ',' || ch == ']' || ch == '}' {
954 break;
955 }
956 self.pos += 1;
957 }
958 let token: String = self.chars[start..self.pos].iter().collect();
959 let trimmed = token.trim();
960 if trimmed.is_empty() {
961 return None;
962 }
963 if matches!(trimmed, "true" | "false" | "null") {
964 return Some(trimmed.to_string());
965 }
966 if trimmed.parse::<i64>().is_ok() || trimmed.parse::<f64>().is_ok() {
967 return Some(trimmed.to_string());
968 }
969 serde_json::to_string(trimmed).ok()
970 }
971
972 fn expect(&mut self, expected: char) -> Option<()> {
973 self.skip_ws();

Callers 1

parse_valueMethod · 0.80

Calls 2

peekMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected