Post Reply 
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 Smile

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: monic part 6: the mC programming language and compiler - robve - 06-25-2022 02:04 PM



User(s) browsing this thread: 1 Guest(s)