limbo_sqlite3_parser/parser/ast/
parameterinfo_traits.rs1use super::fmt::TokenStream;
12use crate::dialect::TokenType::{self, *};
13use std::num::ParseIntError;
14use std::str::{self, FromStr};
15
16use super::types_11::ParameterInfo;
17
18impl TokenStream for ParameterInfo {
20 type Error = ParseIntError;
21
22 fn append(&mut self, ty: TokenType, value: Option<&str>) -> Result<(), Self::Error> {
23 if ty == TK_VARIABLE {
24 if let Some(variable) = value {
25 if variable == "?" {
26 self.count = self.count.saturating_add(1);
27 } else if variable.as_bytes()[0] == b'?' {
28 let n = u32::from_str(&variable[1..])?;
29 if n > self.count {
30 self.count = n;
31 }
32 } else if self.names.insert(variable.to_owned()) {
33 self.count = self.count.saturating_add(1);
34 }
35 }
36 }
37 Ok(())
38 }
39}