Compare commits

...

5 Commits

Author SHA1 Message Date
Janneke Nieuwenhuizen 07ae24e40d squash! mescc: Fix switch statements' fallthrough 2023-09-17 12:55:19 +02:00
Janneke Nieuwenhuizen 9506777449 Revert "squash! mescc: Fix switch statements' fallthrough --support mes"
This reverts commit ef4f4bb25a.
2023-09-17 12:55:19 +02:00
Janneke Nieuwenhuizen eac61918dd Revert "squash! squash! mescc: Fix switch statements' fallthrough --support mes"
This reverts commit 3266f6a834.
2023-09-17 12:55:19 +02:00
Janneke Nieuwenhuizen 1de4454036 squash! squash! mescc: Fix switch statements' fallthrough --support mes 2023-09-17 12:55:19 +02:00
Janneke Nieuwenhuizen a258c212da squash! mescc: Fix switch statements' fallthrough --support mes 2023-09-17 12:55:19 +02:00
1 changed files with 21 additions and 23 deletions

View File

@ -1791,29 +1791,27 @@
(set! i (1+ i)))
n))))
(define (flatten-cases c)
(define (flatten-case case)
(pmatch case
((case ,test (case . ,body))
(append `((case ,test (expr-stmt))) (flatten-case `(case ,@body))))
((case ,test ,casebody (case . ,body))
(append `((case ,test ,casebody)) (flatten-case `(case ,@body))))
((default (case . ,body))
(append `((default (expr-stmt))) (flatten-case `(case ,@body))))
((default ,defbody (case . ,body))
(append `((default ,defbody)) (flatten-case `(case ,@body))))
((case ,test (default . ,body))
(append `((case ,test (expr-stmt))) (flatten-case `(default ,@body))))
((default ,rest)
(list case))
((case ,test)
(list case))
((case ,test ,expr)
(list case))
(,s (list s))))
(fold (lambda (x acc) (append acc (flatten-case x))) '() c))
(define (flatten-cases c)
(define (flatten-case o)
(pmatch o
((case ,test (case . ,body))
(cons `(case ,test (expr-stmt)) (flatten-case `(case ,@body))))
((case ,test ,case-body (case . ,body))
(cons `(case ,test ,case-body) (flatten-case `(case ,@body))))
((default (case . ,body))
(cons `(default (expr-stmt)) (flatten-case `(case ,@body))))
((default ,default-body (case . ,body))
(cons `(default ,default-body) (flatten-case `(case ,@body))))
((case ,test (default . ,body))
(cons `(case ,test (expr-stmt)) (flatten-case `(default ,@body))))
((default ,rest)
(list o))
((case ,test)
(list o))
((case ,test ,expr)
(list o))
(,s (list s))))
(fold (lambda (x acc) (append acc (flatten-case x))) '() c))
(let* ((info (append-text info (ast->comment `(switch ,expr (compd-stmt (block-item-list (ellipsis)))))))
(statements (flatten-cases statements))