仅当至少两个参数给它时,获得宏观关键字才能匹配

发布于 2025-01-31 22:39:12 字数 1292 浏览 2 评论 0原文

我正在尝试为宏变压器(命名=)实现一个关键字(命名=)(命名latex),该关键字仅在至少两个参数时才能匹配。我的尝试是:

     ((_ (= a b))
      `(,@(latex a) "=" ,@(latex b)))
     ((_ (= a b ...))
      `(,@(latex a) "=" ,@(latex (= b ...))))

但是,当仅给出一个参数与=并给出不良结果时,此实现匹配。下面给出了各种输入的输出表。

输入到 a>显示的结果注释
==ok(否匹配)
(=)(=)确定(no Match)
(= a)a =(=(=)bad Match 。结果应为(= a)
(= ab)a = bok(match)
(= abc)a = b = cok(匹配)
(= abcd)a = b = b = c = dok(匹配)

您可以查看<< 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 latexDisplayed Resultcomment
==ok (no match)
(=)(=)ok (no match)
(= a)a=(=)bad match. result should be (= a)
(= a b)a=bok (match)
(= a b c)a=b=cok (match)
(= a b c d)a=b=c=dok (match)

You may view the source file or the project page if you require more context.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文