mirror of
https://github.com/rm-dr/daisy
synced 2025-04-04 04:18:02 -07:00
31 lines
584 B
Rust
31 lines
584 B
Rust
use crate::parser::tokenize::Token;
|
|
|
|
pub fn replace_pre(g: &mut Token) -> Result<(), ()> {
|
|
|
|
match g {
|
|
Token::PreGroup(_, ref mut vec) => {
|
|
for i in vec.iter_mut() {
|
|
replace_pre(i)?;
|
|
}
|
|
},
|
|
Token::PreNumber(_, s) => {
|
|
let n = match s.parse() {
|
|
Ok(n) => n,
|
|
Err(_) => panic!()
|
|
};
|
|
*g = Token::Number(n);
|
|
}
|
|
Token::PreWord(l, ref s) => {
|
|
if s == "mod" {
|
|
*g = Token::PreOperator(*l, String::from("mod"));
|
|
} else {
|
|
return Err(());
|
|
//new.push_back(t);
|
|
}
|
|
},
|
|
Token::PreOperator(_, _) => {},
|
|
_ => { panic!(); }
|
|
};
|
|
|
|
return Ok(());
|
|
} |