从 haskell 中的文件中读取一个又一个的令牌

发布于 2024-08-17 18:43:13 字数 89 浏览 1 评论 0原文

我想通过每次加载变量中的下一个令牌来从 Visual Haskell Studio 中的文件中读取一个又一个令牌。 例如:getNextToken。 谢谢!! :)

I want to read from a file in Visual Haskell Studio, token after token, by loading each time the next token in a variable.
For example: getNextToken.
Thanks!! :)

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

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

发布评论

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

评论(2

话少情深 2024-08-24 18:43:13

您可以使用 Alex,它是一个词法分析器(它将字符串拆分为标记列表)。然后你就可以对令牌列表做任何你想做的事情。如果你真的想以程序的方式“加载”它们并将它们放入变量中,我不确定 Haskell 是否是执行此操作的正确语言。

You can use Alex, which is a lexer (which split a string into a list of tokens). Then you can do whatever you want with the token list. If you really want to "load" them and put them in a variable, in a procedural way , I'm not sure Haskell is the right language to do it.

蓝咒 2024-08-24 18:43:13

好吧,正确的答案有点复杂:

使用像 Parsec 这样的解析器组合器库,它可以让你完整定义“令牌”一词的含义,该含义因上下文而异。

Well, the right answer is somewhat complicated:

Use a parser combinator library like Parsec that will let you fully define the meaning of the word 'token', which varies from context to context.

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