mirror of
https://github.com/rm-dr/daisy
synced 2025-02-21 22:49:24 -08:00
Added basic number parser
This commit is contained in:
parent
0fe50e8210
commit
83961409a7
@ -2,7 +2,7 @@
|
||||
- Fix documentation and variable names
|
||||
- implicit multiply
|
||||
- Function application
|
||||
- Syntax check (parenthesis, argument type)
|
||||
- Syntax check (parenthesis, argument type, position of error)
|
||||
|
||||
# Eventually
|
||||
- rationals
|
||||
|
@ -20,6 +20,14 @@ pub fn replace_words(g: &mut Token) -> Result<(), ()> {
|
||||
replace_words(&mut t)?;
|
||||
new.push_back(t);
|
||||
},
|
||||
Token::PreNumber(ref s) => {
|
||||
let n = match s.parse() {
|
||||
Ok(n) => n,
|
||||
Err(_) => panic!()
|
||||
};
|
||||
|
||||
new.push_back(Token::Number(n));
|
||||
}
|
||||
Token::PreWord(ref s) => {
|
||||
if s == "to" {
|
||||
new.push_back(Token::PreOperator(String::from("to")));
|
||||
|
@ -11,7 +11,13 @@ pub enum Token {
|
||||
PreNumber(String),
|
||||
PreWord(String),
|
||||
|
||||
// All PreGroups should vanish after operator folding
|
||||
// All PreOperators should become Operators
|
||||
// All PreNumbers should become Numbers
|
||||
// All PreWords should become TODO.
|
||||
|
||||
// Only used in tree
|
||||
Number(f64),
|
||||
Multiply(VecDeque<Token>),
|
||||
Divide(VecDeque<Token>),
|
||||
Add(VecDeque<Token>),
|
||||
|
Loading…
x
Reference in New Issue
Block a user