monic part 6: the mC programming language and compiler
|
06-25-2022, 02:04 PM
Post: #13
|
|||
|
|||
RE: monic part 6: the mC programming language and compiler
Looks like a great update to the project!
(06-22-2022 01:50 AM)F-73P Wrote: Thanks Sylvain, you are right. Implementing switch is quite a challenge - I would like it to conform to standard C but I just can't figure it out. Below is the code for switch in the parser, there's already a lot going on! One of the nice things about switch is the fall-through, so multiple cases can be combined that would otherwise break, like so: case A: case B: case C: <code> This would not work if a break is placed between case A and case B and between case B and case C Furthermore, the default arm can be placed before cases, like so: case A: <code> break; default: <code> // fall-through case B: <code> The default arm will be taken when cases A and B do not match. Why write code like this? Well, the fall-through from the default arm to case B is useful! Some switcheroo, in case you've not seen it before - Rob "I count on old friends to remain rational" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)