ref: 4c7f40659c29208f37c51acc35d4b1887d8e0f64
parent: 0747dba4da50e96b633a31912a491a62f8378159
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Jun 25 00:20:10 EDT 2024
allow | as bor in expressions
--- a/gen.rkt
+++ b/gen.rkt
@@ -48,7 +48,7 @@
[(number? e) e]
[(list? e)
(match e
- [(list op x y) (~a "(" (fmt x) op (fmt y) ")")])]
+ [(list op x y) (~a "(" (fmt x) (if (equal? op 'bor) "|" op) (fmt y) ")")])]
[(and (symbol? e) (or (enum? e) (extra-context-ref? e))) (~a e)]
[(symbol? e) (~a "v->" e)]))
(and e (fmt e)))
@@ -88,9 +88,7 @@
#:when ((listof number?) n)
(block (~a "if(" (string-join (map (λ (n) (~a (fmt-ref ref) " " op " " n)) n) " || ") ")")
(indent lst))]
- [(list op ref e)
- #:when (list? e)
- (block (~a "if(" (fmt-expr cond) ")") (indent lst))]))
+ [(list op ref e) (block (~a "if(" (fmt-expr cond) ")") (indent lst))]))
(define (invert-c op)
(match op
@@ -476,7 +474,7 @@
(define-syntax-class arithop
#:description "arithmetical operator"
(pattern op:id
- #:when (member (syntax-e #'op) '(+ - / * &))))
+ #:when (member (syntax-e #'op) '(+ - / * & bor))))
(define-syntax-class oref
#:description "extra context field reference"