flofriday / Moose

🐐 A new fun programming language
MIT License
6 stars 1 forks source link

Impement else if #21

Closed flofriday closed 1 year ago

flofriday commented 1 year ago

Example

age = 43

if age < 5 {
  print("Aaaaw soo cute")
} else if age == 5 {
  print("Aren't you a brave young man")
} else {
  print("Do you have some time to talk about our lord and savior, the rust programming language?")
}

Note

This should be easily possible if we don't require else to be followed by a block statement.

Jozott00 commented 1 year ago

Yes, I think internally we should move the else if as new if inside the else block of the outer if. So we don't have to change anything in the typechecker and interpreter... It's just a little change inside the parser 🤔

flofriday commented 1 year ago

Supporting, else-if was really just a limitation of the parser and removing it worked imediatly. This means we now support else-ifs :tada: