FSLex 未知错误

发布于 2024-09-18 13:33:23 字数 366 浏览 3 评论 0原文

我的 FSLex 遇到了一些无法解决的问题...我所知道的是 fslex.exe 以代码 1 退出...

顶部的 F# 代码在 F# Interactive 中进行了测试,因此问题不存在(我看不出如何)。

词法分析器: http://pastebin.com/qnDnUh59

和 Parser.fsi: http://pastebin.com/sGyLqZbN

谢谢, 拉蒙.

I got some problem with my FSLex which I can't solve... All I know is that fslex.exe exited with code 1...

The F# code at the top was tested in F# Interactive, so the problem isn't there (I can't see how).

Lexer:
http://pastebin.com/qnDnUh59

And Parser.fsi:
http://pastebin.com/sGyLqZbN

Thanks,
Ramon.

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

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

发布评论

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

评论(1

七禾 2024-09-25 13:33:23

非零错误意味着词法分析器失败,通常它也会描述失败。当我编译时,我得到了 exited with code 1 以及以下内容:

Unexpected character '\'

let id = [\w'.']+ 
----------^

Lexer does not like char Lites Outside of Quotes, and it does not Understanding the meaning of \w任何一个。根据FsLex源代码,FsLex仅理解以下转义序列:

let escape c =
 match c with
 | '\\' -> '\\'
 | '\'' -> '\''
 | 'n' -> '\n'
 | 't' -> '\t'
 | 'b' -> '\b'
 | 'r' -> '\r'
 | c -> c

你的词法分析器的这个固定版本对我来说编译得很好: http://pastebin.com/QGNk3VKD

Non-zero error means the lexer failed, usually it'll describe the failure too. When I compile, I get exited with code 1 along with this:

Unexpected character '\'

let id = [\w'.']+ 
----------^

Lexer doesn't like char literals outside of quotes, and it doesn't understand the meaning of \w either. According to FsLex source code, FsLex only understands the following escape sequences:

let escape c =
 match c with
 | '\\' -> '\\'
 | '\'' -> '\''
 | 'n' -> '\n'
 | 't' -> '\t'
 | 'b' -> '\b'
 | 'r' -> '\r'
 | c -> c

This fixed version of your lexer compiles fine for me: http://pastebin.com/QGNk3VKD

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