forked from alex-eg/sex
refuse a malformed enumerator
Anything in the list but a name or (name value) was taken apart as if it were the pair: (! 1 2) came out ! = 1.
This commit is contained in:
@@ -574,8 +574,14 @@ forms, and what remains."
|
||||
;;; red -> red, (wire-varint 0) -> wire_varint = 0
|
||||
(define (walk-enumerator value)
|
||||
(match value
|
||||
((name expr) (list (atom-to-fmt-c name) (walk-expr expr)))
|
||||
(_ (atom-to-fmt-c value))))
|
||||
(((? enumerator-name? name) expr) (list (atom-to-fmt-c name) (walk-expr expr)))
|
||||
((? enumerator-name?) (atom-to-fmt-c value))
|
||||
;; anything else was taken apart as if it were the pair: (! 1 2)
|
||||
;; came out `! = 1'
|
||||
(_ (sex-error value "an enumerator is a name, or (name value)" value))))
|
||||
|
||||
(define (enumerator-name? x)
|
||||
(and (symbol? x) (not (operator-arity x))))
|
||||
|
||||
(define (walk-extern form)
|
||||
(match form
|
||||
|
||||
Reference in New Issue
Block a user