create-your-own-lang-with-rust
create-your-own-lang-with-rust copied to clipboard
First number in expression cannot be negative [BUG]
Description
When running the calculator, the first number in a full line cannot be a negative number. In either the interpreter, JIT, or VM, it errors with the following message: called `Result::unwrap()\` on an `Err` value: Error { variant: ParsingError { positives: [EOI], negatives: [] }, location: Pos(3), line_col: Pos((1, 4)), path: None, line: "-1 + 2", continued_line: None }
.
To Reproduce
- Run the calculator compiler by
cargo run --bin repl --features vm | jit | interpreter
. - Give the input
-NUMBER + NUMBER
such as-2 + 5
. - Output gives an error.
Expected behavior
Instead of giving an error the interpreter should return the calculated result. For example, -2 + 5
should output 3
.