From 7b14d7ccb3d26cd7500900aaf157dc1d00fe5f97 Mon Sep 17 00:00:00 2001 From: Rusty Striker Date: Thu, 4 Apr 2024 09:58:44 +0300 Subject: [PATCH] switch partial explanation --- parser.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parser.py b/parser.py index 17c45a7..1918ddd 100644 --- a/parser.py +++ b/parser.py @@ -209,6 +209,10 @@ class Parser(sly.Parser): @_('SWITCH "(" expression ")" "{" caselist DEFAULT ":" stmtlist "}"') def switch_stmt(self, p): + # The way this works is, every caselist (and case) return a list of where to put the comparison and jump + # also, where to jump(as in, where is the next case) + # they also add a little jump over the next case check, which would probably be + # removed by the optimizer if there is a break (since we will have 2 jumps one after the other) exp = p[2] cases = p[5] if exp.is_float: