在 asdf defsystem 中选择 :file 组件的扩展
Choose extension of :file component in asdf defsystem
我 90% 确定答案在 this paragraph of the asdf documentation 中,但我似乎无法理解。
我想知道我是否能够将不以“.lisp”结尾的源文件作为文件组件。例如,通常我有类似
的东西
(asdf:defsystem #:hash-bang-lang
:serial t
:depends-on (#:named-readtables)
:components ((:file "package")
(:file "hash-bang-lang")))
如您所见,:file 组件未指定扩展名。我想知道我是否可以加载不以“.lisp”结尾的 lisp 文件。
我想要这个的原因有点奇怪,但对问题没有影响,所以请随意跳过下一点。
我有一些文件 "test.mylang",它以以下内容开头
(in-package :hash-bang-lang)
(in-readtable hash-bang)
#!mylang
..rest of file..
#!mylang
是一个 reader 宏,它让我的 #'mylang 函数控制解析文件的其余部分。因此,如果我有 python 的解析器,我会使用 #!python 并且我的 #'python 函数将进行解析。
在那些情况下,我希望有 .mylang
或 .py
扩展名,以便编辑人员立即知道如何突出显示代码,即使它无论如何都会作为 lisp 加载。
谢谢大家
:file
组件类型强制文件扩展名为 .lisp
。如果你需要一些其他的扩展,你需要一个新的组件类型。
(defpackage #:mylang-system
(:use #:cl #:asdf))
(in-package #:mylang-system)
(defclass mylang-file (cl-source-file)
((type :initform "mylang")))
(defsystem test-ext
:encoding :utf-8
:components ((:file "package")
(:mylang-file "hash-bang-lang")))
我 90% 确定答案在 this paragraph of the asdf documentation 中,但我似乎无法理解。 我想知道我是否能够将不以“.lisp”结尾的源文件作为文件组件。例如,通常我有类似
的东西(asdf:defsystem #:hash-bang-lang
:serial t
:depends-on (#:named-readtables)
:components ((:file "package")
(:file "hash-bang-lang")))
如您所见,:file 组件未指定扩展名。我想知道我是否可以加载不以“.lisp”结尾的 lisp 文件。
我想要这个的原因有点奇怪,但对问题没有影响,所以请随意跳过下一点。
我有一些文件 "test.mylang",它以以下内容开头
(in-package :hash-bang-lang)
(in-readtable hash-bang)
#!mylang
..rest of file..
#!mylang
是一个 reader 宏,它让我的 #'mylang 函数控制解析文件的其余部分。因此,如果我有 python 的解析器,我会使用 #!python 并且我的 #'python 函数将进行解析。
在那些情况下,我希望有 .mylang
或 .py
扩展名,以便编辑人员立即知道如何突出显示代码,即使它无论如何都会作为 lisp 加载。
谢谢大家
:file
组件类型强制文件扩展名为 .lisp
。如果你需要一些其他的扩展,你需要一个新的组件类型。
(defpackage #:mylang-system
(:use #:cl #:asdf))
(in-package #:mylang-system)
(defclass mylang-file (cl-source-file)
((type :initform "mylang")))
(defsystem test-ext
:encoding :utf-8
:components ((:file "package")
(:mylang-file "hash-bang-lang")))