name the identifier predicates with a ?
sexc spells ? in a C name now (sex#49). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
11
src/json.sex
11
src/json.sex
@@ -6,12 +6,11 @@
|
||||
(pub include "cJSON.h")
|
||||
(include stdio.h stdlib.h string.h ctype.h)
|
||||
|
||||
;; TODO sex#49: rename to ident-start? once ? is mangled in names.
|
||||
(fn ident-start-char ((c char)) bool
|
||||
(fn ident-start? ((c char)) bool
|
||||
(return (|| (isalpha (cast c u8)) (== c #\_) (== c #\$))))
|
||||
|
||||
(fn ident-char ((c char)) bool
|
||||
(return (|| (ident-start-char c) (isdigit (cast c u8)))))
|
||||
(fn ident-char? ((c char)) bool
|
||||
(return (|| (ident-start? c) (isdigit (cast c u8)))))
|
||||
|
||||
;;; Drops a comma that was the last thing written before a closing
|
||||
;;; bracket: `[1, 2, ]' -> `[1, 2 ]'.
|
||||
@@ -58,10 +57,10 @@
|
||||
(do
|
||||
(= n (drop-trailing-comma out n))
|
||||
(= [out n] c) (+= n 1) (+= p 1))
|
||||
(ident-start-char c)
|
||||
(ident-start? c)
|
||||
(do
|
||||
(var start (* const char) p)
|
||||
(while (ident-char (* p))
|
||||
(while (ident-char? (* p))
|
||||
(+= p 1))
|
||||
(var len size-t (cast (- p start) size-t))
|
||||
(var bare bool (|| (&& (== len 4) (|| (== (strncmp start "true" 4) 0)
|
||||
|
||||
Reference in New Issue
Block a user