Closed TheOtterlord closed 4 years ago
Looking good!
Maybe something nice next would be to add tests that we expect the code to fail to compile like when we use let in the global scope.
The parse_str
function has .unwrap()
at the end and the unwrap function expects the value to be Ok
if not it will panic.
Maybe add an extra function like parse_str_fail
and inside the function do something like this:
let res = Parse::par...
without the unwrap because we expect a failureif let Ok(parsed_result) = ...
statement check if the response is Ok (if let documentation, Result documentation)parsed_result
to the message
Parser
struct because otherwise it's not printable (for an example see the Function
struct)parsed_result
to the message by using {:?}
instaid of {}
the {:?}
is for printing debug information, {}
is for printing the (Display)[https://doc.rust-lang.org/std/fmt/trait.Display.html] trait and the display trait should generally pretty print data.Sure.
Tests like this will be really useful to make sure we do not parse any invalid code accidently. I'll have a go at that now.
Let me know if there are any other cases you think I should cover.
Hello.
As I am still learning rust, I have not done any parsing yet. I'm just getting use to the project structure and will hopefully begin parsing soon.
This PR adds a few things including documentation for development and for usage.
docs
folder to hold all documentation for usage and for development. Check out my fork if you want a closer look.example.gpl
file. You specified anexample
file in main, but there was no such file and so runningcargo run
always failed. I thought I'd add a file that contains all currently implemented components. This way, we can usecargo run
to get access to the token stream etc...cargo test function
and run all function tests.I've run our tests and currently we have 13 tests that resolve as follows.
I'm happy to write more documentation if you think something is missing. Feel free to change anything you think I've messed up.