mirror of https://github.com/rm-dr/daisy
Added basic number parser
parent
0fe50e8210
commit
83961409a7
|
@ -2,7 +2,7 @@
|
||||||
- Fix documentation and variable names
|
- Fix documentation and variable names
|
||||||
- implicit multiply
|
- implicit multiply
|
||||||
- Function application
|
- Function application
|
||||||
- Syntax check (parenthesis, argument type)
|
- Syntax check (parenthesis, argument type, position of error)
|
||||||
|
|
||||||
# Eventually
|
# Eventually
|
||||||
- rationals
|
- rationals
|
||||||
|
|
|
@ -20,6 +20,14 @@ pub fn replace_words(g: &mut Token) -> Result<(), ()> {
|
||||||
replace_words(&mut t)?;
|
replace_words(&mut t)?;
|
||||||
new.push_back(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) => {
|
Token::PreWord(ref s) => {
|
||||||
if s == "to" {
|
if s == "to" {
|
||||||
new.push_back(Token::PreOperator(String::from("to")));
|
new.push_back(Token::PreOperator(String::from("to")));
|
||||||
|
|
|
@ -11,7 +11,13 @@ pub enum Token {
|
||||||
PreNumber(String),
|
PreNumber(String),
|
||||||
PreWord(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
|
// Only used in tree
|
||||||
|
Number(f64),
|
||||||
Multiply(VecDeque<Token>),
|
Multiply(VecDeque<Token>),
|
||||||
Divide(VecDeque<Token>),
|
Divide(VecDeque<Token>),
|
||||||
Add(VecDeque<Token>),
|
Add(VecDeque<Token>),
|
||||||
|
|
Loading…
Reference in New Issue