pull/2/head
Mark 2023-04-01 16:43:33 -07:00
parent 047c900193
commit e0210a8f09
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 10 additions and 10 deletions

View File

@ -49,16 +49,6 @@ pub(in crate::parser) fn tokenize(input: &String) -> VecDeque<PreToken> {
for (i, c) in input.chars().enumerate() { for (i, c) in input.chars().enumerate() {
match c { match c {
// The minus sign can be both a Negative and an Operator.
// Needs special treatment.
'-' => {
push_token(&mut g, t, i);
t = Some(PreToken::PreOperator(
LineLocation{pos: i, len: 1},
String::from("-")
));
},
// Number // Number
// Commas act just like dots. // Commas act just like dots.
',' | '.' | '0'..='9' => { ',' | '.' | '0'..='9' => {
@ -78,6 +68,16 @@ pub(in crate::parser) fn tokenize(input: &String) -> VecDeque<PreToken> {
}; };
}, },
// The minus sign can be both a Negative and an Operator.
// Needs special treatment, always starts a new token.
'-' => {
push_token(&mut g, t, i);
t = Some(PreToken::PreOperator(
LineLocation{pos: i, len: 1},
String::from("-")
));
},
// Operator // Operator
'*'|'×'|'/'|'÷'| '*'|'×'|'/'|'÷'|
'+'|'^'|'!'|'%' '+'|'^'|'!'|'%'