仅当至少两个参数给它时,获得宏观关键字才能匹配
我正在尝试为宏变压器(命名=
)实现一个关键字(命名=
)(命名latex
),该关键字仅在至少两个参数时才能匹配。我的尝试是:
((_ (= a b))
`(,@(latex a) "=" ,@(latex b)))
((_ (= a b ...))
`(,@(latex a) "=" ,@(latex (= b ...))))
但是,当仅给出一个参数与=
并给出不良结果时,此实现匹配。下面给出了各种输入的输出表。
输入到 a> | 显示的结果 | 注释 |
---|---|---|
= | = | ok(否匹配) |
(=) | (=) | 确定(no Match) |
(= a) | a =(=(=) | bad Match 。结果应为(= a) |
(= ab) | a = b | ok(match) |
(= abc) | a = b = c | ok(匹配) |
(= abcd) | a = b = b = c = d | ok(匹配) |
您可以查看<< a href =“ https://gitlab.com/vyuh/symbolic-mathematics/-/blob/master/master/mac.scm#l164” rel =“ nofollow noreferrer”>源文件或 https://gitlab.com/vyuh/symbolic-mathematics/“ rel =“ nofollow noreferrer”>项目页面如果您需要更多上下文。
I am trying to implement a keyword (named =
) for a macro transformer (named latex
) which is intended to match only if at least two arguments are given to it. My attempt is:
((_ (= a b))
`(,@(latex a) "=" ,@(latex b)))
((_ (= a b ...))
`(,@(latex a) "=" ,@(latex (= b ...))))
but this implementation matches when only one argument is given to =
and gives an undesirable result. A table of outputs for various inputs is given below.
Input to latex | Displayed Result | comment |
---|---|---|
= | = | ok (no match) |
(=) | (=) | ok (no match) |
(= a) | a=(=) | bad match. result should be (= a) |
(= a b) | a=b | ok (match) |
(= a b c) | a=b=c | ok (match) |
(= a b c d) | a=b=c=d | ok (match) |
You may view the source file or the project page if you require more context.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论