Closed alexapostolu closed 3 years ago
if <expression> {
. Indeed, it is useful, but it also confuses the parsing step with the parser, which I would like to keep distinct, unless there really is a better way to do it -- I'm all ears!Thank you! I will create a new issue with all the ideas you discussed.
I think this would be better if we just started using an argument parser, it'll be better in the long run.
yeah, true
I added a version command if that's helpful :)
Also just some things I noticed
For your lexer, instead of getting all the tokens at once, you could also get them when you need them, like this:
It doesn't really matter which way you do it. I kinda like the second way thought since you have more control over the lexing process, and it's much easier to deal with syntax errors.
For your parser, you have a lot of duplicate code with your functions:
comp
,add
,mult
,unary
. I would just suggest havingunary
andbinary
.Same thing with
types.rs
, there's a bunch of duplicate code. I'm not sure how it works in Rust, but you could try to have a generic binary expression function, and just pass in a lambda like this:Hope it helps :D