I’m a total newbie trying to learn RUST by developing a ‘faux’ BBC Micro Emulator…
Buy ‘faux’ I mean that I’m not emulating the hardware as such, but simply developing a BASIC Interpreter that emulates the end result. At present my code can display a screen, render text, accept keyboard input, store basic programs, plays sound and can already cater for some rudimentary commands such as NEW, CLS, LIST and so on.
The time came for me to get into the nitty-gritty of language parsing. So I decided to make use of Dmitry Soshnikov’s LALR(1) parser, to which I am passing values by having it declared as an external crate, then a declared use, and then priming it using
let mut parser = Parser::new();
In my error below, if I replace
“2 + 2” then I get ‘4’ as expected. But when I try to use a referenced variable as below ( a String containing ‘2 + 2’ ), then I get the borrowing error.
_parameter_line_with_spaces does not live long enough
540 | let _result = parser.parse (&_parameter_line_with_spaces);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
577 | }
| - borrowed value only lives until here
= note: borrowed value must be valid for the static lifetime…
All comments gratefully received.