spell ? and ! in names as letters C takes

A Lisp predicate came out as ident_start?, which no C compiler reads.
ʔ and ꜝ are letters that look the part; ǃ looks closer, but clang flags
it as a homoglyph of `!' at every use.

Fixes #49.
This commit is contained in:
2026-10-09 16:01:32 +03:00
parent b5de28342b
commit 5a887c0654
3 changed files with 30 additions and 6 deletions

View File

@@ -102,15 +102,22 @@ forms, and what remains."
;;; hand-written vec2__length would collide, and an identifier holding
;;; `__' is reserved in C++, which a pub header may be included from.
;;; Lifted closures carry a ƛ for the same reason.
;;;
;;; zero? -> zeroʔ, clear! -> clearꜝ: a glottal stop and a raised
;;; exclamation mark, both letters. Not the retroflex click ǃ, which
;;; looks more like `!' -- enough that clang warns at every use.
(define +name-spellings+
'(("-(?!>)" . "_") ("/" . "ː") ("\\?" . "ʔ") ("!" . "ꜝ")))
(define (unkebabify sym)
(case sym
((- -- -> -= / /=) sym) ; bare operators, not names
((- -- -> -= / /= ! != ?) sym) ; bare operators, not names
(else
(string->symbol
(irregex-replace/all
"/"
(irregex-replace/all "-(?!>)" (symbol->string sym) "_")
"ː")))))
(fold (lambda (spelling name)
(irregex-replace/all (car spelling) name (cdr spelling)))
(symbol->string sym)
+name-spellings+)))))
(define (atom-to-fmt-c atom)
(case atom