aboutsummaryrefslogtreecommitdiff
path: root/module/c/operators.scm
blob: 910dc8a91795ae21c7aae48de4fa998dd97d53b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(define-module (c operators)
  :export (wordy-binary-operators
           symbol-binary-operators
           binary-operators))


;;; Simple operators are those which can be combined with '='
(define simple-operators
  `(+ - * / & ,(symbol #\|) ^ << >> % < > =))

;; apparently part of C
;; https://en.cppreference.com/w/cpp/language/operator_alternative
(define wordy-binary-operators
  '(bitand and_eq and bitor or_eq or xor_eq xor not_eq))

(define symbol-binary-operators
  (append (map (lambda (x) (symbol-append x '=)) simple-operators)
          `(&& ,(symbol #\| #\|) != ,(symbol #\,)
               -> ,(symbol #\.))
          simple-operators))

(define binary-operators
  (append symbol-binary-operators
          wordy-binary-operators))