ml-lex 中正则表达式的行结束符

发布于 2025-01-04 07:03:57 字数 409 浏览 2 评论 0 原文

ml-lex 中正则表达式的行结束符是什么?
$”用于捕获大多数其他语言的正则表达式中的行尾字符,但是如果我在 ml-lex 的情况下使用它,它会给我一个错误 -

mllex a.lex
ml-lex: error, line 45: lookahead is unimplemented
unhandled exception: Error 

我目前正在为所有正则表达式附加一个额外的 \n 字符,以显式捕获行尾字符。然而,删除捕获的额外 \n 字符会使代码变得丑陋。

我在某处读到 $ 未在 ml-lex 中实现。
那么,我的问题还有其他解决方案吗?请帮忙。

What is the end of line character for regular expressions in ml-lex?
"$" is used for catching the end of line character in regular expressions in most other languages, but if I use it in case of ml-lex, it gives me an error -

mllex a.lex
ml-lex: error, line 45: lookahead is unimplemented
unhandled exception: Error 

I am currently appending all my regular expressions with an additional \n character for explicitly catching the end of line character. However removing the caught extra \n character is making the code ugly.

I read somewhere that $ is not implemented in ml-lex.
So, can there be any other solution for my problem? Please help.

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

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

发布评论

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

评论(1

却一份温柔 2025-01-11 07:03:57

不幸的是,根据 $ 字符="nofollow">本手册

“C Lex $ 的美元符号未实现,因为它是一个
涉及换行符的向前查找的缩写(即
它是 /\n) 的缩写。”

本用户指南中也注明了这一点:

“C Lex $ 的美元符号未实现,因为它是一个
涉及换行符的向前查找的缩写,即
是 /\n 的缩写。”

所以...这至少可以解释(并支持您对 ML-Lex 中未实现的 $ 的阅读)。不幸的是,这可能意味着至少现在,您可能只需要继续使用现有的方法来检查这些行尾......即使它看起来不太干净。

Unfortunately, it looks like the $ character is not implemented in ML-Lex according to this manual:

"The dollar sign of C Lex $ is not implemented, since it is an
abbreviation for lookahead involving the newline character (that is,
it is an abbreviation for /\n)."

And it is also noted in this user guide:

"The dollar sign of C Lex $ is not implemented, since it is an
abbreviation for lookahead involving the newline character that is, it
is an abbreviation for /\n."

So... that would at least explain (and back up your reading of the $ not being implemented in ML-Lex). Unfortunately, that probably means that for now, at least, you might just need to keep using your existing method for checking those end-of-lines... even it doesn't look super clean.

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