europalang / Europa-Lang

A fun and simple language with NO classes whatsoever!
MIT License
22 stars 5 forks source link

Added break and continue errors #14

Closed seanlnge closed 3 years ago

seanlnge commented 3 years ago

Added errors for break and continue statements, as well as creating a Return enum to store Type, Break, Continue, and Err.

cursorweb commented 3 years ago

Hmm, don't you think it's still better to have an error in the errortype enum, like:

enum ErrorType {
  ...,
  RunTime(...)
}

so that way we can use the ? operator for things like if statements, and we can do error matching in where it actually matters, like in while loops and functions.

seanlnge commented 3 years ago

What do you mean? The runtime errortype is in the ErrorType enum.

seanlnge commented 3 years ago

I needed to make a Return enum to store break and continue statements, which required a match expression to check if a Type was provided, so I just decided to put errors in the else-case of that match

cursorweb commented 3 years ago

No, your IResult I mean, it has a return enum when it technically doesn't -- those errors can be handled by rust automatically through the ? operator.

Because they are still errors, they will get returned, and so then it's parent function will handle it. Therefore, while loops and functions would only need the match, while variables can just let it pass. Finally, if it reaches the init stage, all that has to be done would be to print it!