![Kodi Arfer](/assets/img/avatar_default.png)
It was an odd one out by being in hy.core but needing to be called by a qualified name. It's at home in hy.extra.
42 lines
1.7 KiB
Hy
42 lines
1.7 KiB
Hy
;;; Get a frozenset of Hy reserved words
|
|
;;
|
|
;; Copyright (c) 2016 Paul Tagliamonte <paultag@debian.org>
|
|
;;
|
|
;; Permission is hereby granted, free of charge, to any person obtaining a
|
|
;; copy of this software and associated documentation files (the "Software"),
|
|
;; to deal in the Software without restriction, including without limitation
|
|
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
;; and/or sell copies of the Software, and to permit persons to whom the
|
|
;; Software is furnished to do so, subject to the following conditions:
|
|
;;
|
|
;; The above copyright notice and this permission notice shall be included in
|
|
;; all copies or substantial portions of the Software.
|
|
;;
|
|
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
;; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
;; DEALINGS IN THE SOFTWARE.
|
|
|
|
(import hy sys keyword)
|
|
|
|
(setv _cache None)
|
|
|
|
(defn names []
|
|
"Return a frozenset of reserved symbol names.
|
|
|
|
The result of the first call is cached."
|
|
(global _cache)
|
|
(if (is _cache None) (do
|
|
(setv unmangle (. sys.modules ["hy.lex.parser"] hy_symbol_unmangle))
|
|
(setv _cache (frozenset (map unmangle (+
|
|
hy.core.language.*exports*
|
|
hy.core.shadow.*exports*
|
|
(list (.keys (get hy.macros._hy_macros None)))
|
|
keyword.kwlist
|
|
(list-comp k [k (.keys hy.compiler.-compile-table)]
|
|
(isinstance k hy._compat.string-types))))))))
|
|
_cache)
|