Browse Source

Fix compound op with identifier first

github-actions
Garrit Franke 3 years ago
parent
commit
c1ead8ddc9
  1. 1
      TODO
  2. 5
      examples/playground.sb
  3. 2
      src/parser/mod.rs
  4. 1
      src/parser/tests.rs

1
TODO

@ -1,5 +1,4 @@
# Bugs # Bugs
- Fix `parser::tests::test_parse_compound_ops_with_identifier_first` test
# Features # Features

5
examples/playground.sb

@ -1,12 +1,11 @@
main :: () { fn main() {
let num = 10 let num = 10
return fib(num) return fib(num)
} }
fib :: (n) { fn fib(n) {
if 1 >= n { if 1 >= n {
return n return n
} }
return fib(n-1) + fib(n-2) return fib(n-1) + fib(n-2)
} }

2
src/parser/mod.rs

@ -292,7 +292,7 @@ impl Parser {
} }
} }
_ => match BinOp::try_from(self.peek().ok_or("Could not peek token")?.kind) { _ => match BinOp::try_from(self.peek().ok_or("Could not peek token")?.kind) {
Ok(_) => self.parse_bin_op(None)?, Ok(_) => self.parse_bin_op(Some(Expression::Variable(token.raw)))?,
Err(_) => Expression::Variable(val), Err(_) => Expression::Variable(val),
}, },
}; };

1
src/parser/tests.rs

@ -211,7 +211,6 @@ fn test_parse_compound_ops_with_identifier() {
} }
#[test] #[test]
#[ignore]
fn test_parse_compound_ops_with_identifier_first() { fn test_parse_compound_ops_with_identifier_first() {
let raw = " let raw = "
fn main(n) { fn main(n) {

Loading…
Cancel
Save