Rebol 解析:处理空格和复制 var

发布于 2024-07-26 04:26:08 字数 627 浏览 0 评论 0原文

我读了第15章: http://www.rebol.com/docs/core23/ rebolcore-15.html#section-8

spacer: charset reduce [tab newline #" "]
spaces: [some spacer]
rule: ["a" spaces "b" spaces "c"]
parse/all "a b c" rule

没问题,但如果我将规则更改为仅

rule: ["a" spaces copy varb to spaces "c"]
parse/all "a b c" rule

Rebol 控制台输出错误:

** Script Error: Invalid argument: some spacer
** Where: halt-view
** Near: parse/all "a b c" rule
>>

为什么?

谢谢。

I read chapter 15:
http://www.rebol.com/docs/core23/rebolcore-15.html#section-8"

spacer: charset reduce [tab newline #" "]
spaces: [some spacer]
rule: ["a" spaces "b" spaces "c"]
parse/all "a b c" rule

is OK but if I change rule to just

rule: ["a" spaces copy varb to spaces "c"]
parse/all "a b c" rule

Rebol Console outputs error:

** Script Error: Invalid argument: some spacer
** Where: halt-view
** Near: parse/all "a b c" rule
>>

Why ?

Thanks.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愚人国度 2024-08-02 04:26:08

在 REBOL 2 中,PARSE 的 TO 操作的参数不能是复杂的规则 - 它必须是文字值或字符集。 代码[to space]相当于[to [some spacer]],但这是行不通的。 在您的示例中,您可以将 [to space] 转换为 [to spacer space] 并且它应该可以正常工作。

有一些技巧可以解决这个问题,主要涉及将 [to [some spacer]] 重构为 [any non-spacer],其中 non-spacer 是间隔字符集。

预计这一问题将在 REBOL 3 中得到修复,但该修复尚未完成,并且由于 Unicode,补充字符集效果不佳。 现在继续使用 REBOL 2。

In REBOL 2 the argument of the TO operation of PARSE can't be a complex rule - it must be a literal value or character set. The code [to spaces] is equivalent to [to [some spacer]] and that just won't work. In your example you can convert [to spaces] to [to spacer spaces] and it should work just fine.

There are tricks to get around this, that mostly involve refactoring the [to [some spacer]] to be [any non-spacer] where non-spacer is the complement of the spacer character set.

It is intended that this will be fixed in REBOL 3, but that fix hasn't been done yet, and complementing a character set doesn't work as well because of Unicode. Stick with REBOL 2 for now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文