问题标签 [camlp4]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
43 浏览

ocaml - 如何显示来自解析器的位置信息?

Stream.Error当解析器内部发生 a 时,如何显示位置信息?例如:

如何获取流中的位置?有没有办法Stream.count不用手动计算换行符?

0 投票
2 回答
71 浏览

ocaml - Camlp4 解析器函数:表达式具有 int 类型,但表达式应为 float 类型

我正在编写一个简单的解析器函数,它需要一个流中的项目,并返回一个 int,但由于某种原因,编译器出于我无法理解的原因一直期待一个浮点数;特别是考虑到代码实际上是来自 llvm ocaml 教程的示例代码

我已经尝试将这两个变量类型转换为整数,并且通常只是摆弄语法,但是该函数非常简单,我无法弄清楚实际出了什么问题。我知道对于普通函数,可以指定类型, let: type->type但我不知道这将如何与解析器函数一起使用。

这是功能:

这是在也是问题一部分的情况下使用它的更大背景(尽管我不认为它是):

我目前只是获得标准

类型错误。

有谁知道为什么这期待浮动?如何使函数期望一个 int?

编辑:

我现在意识到我现在措辞很糟糕,但是我意识到程序的上下文决定了函数的类型,我在问程序中的什么让它假设函数返回一个 int。似乎它超出了我发布的范围,因此我正在使用与显示的所有内容相关的代码更新我的帖子。

这是相关代码的完整集。很抱歉一开始就没有包括这个。

令牌.ml:

解析器.ml

astml

0 投票
2 回答
71 浏览

syntax - OCaml 保护值后的语法

我不太明白这里使用的语法:

首先,我不明白使用警卫(垂直线)后跟parser. 其次,我似乎找不到[<和包围的条件的相关语法>]

从这里得到代码。提前致谢!

0 投票
1 回答
195 浏览

installation - In Ocaml Camlp5 is not installing (and it is necessary to use Quotations)

In Ocaml 4, I have to use the Quotation module, on its Quotation.add and Quotation.ExStr functions. It seems I have to install the Camlp5 library (seems to be a preprocessor) to do so. Found lots of info about Camlp, like:

But no installation guides, so I tried: opam install camlp5 with the result:

So some dependencies seem not to be there, and I have tried: opam depext --install camlp5 with the result:

So does not seem to work.

The error diagnosis is the same for both commands:

I have been trying similars and alternatives for some hours, and cannot achieve it. Any help?

PS1: I am working in MAC. PS2: If someone wants, my context for this problem is that I want to use the functions of one directory -which is a black box for me-, and all the examples are written with the parser, like <<y+2=5>> so I do not know the grammar and have to achieve to make the parser run.

EDIT 1 (The solution proposed by Ivg)

After trying both commands of the proposed solution by Ivg (answering local::lib in one of the questions and yes on the others), the second of the errors seem to be corrected, when doing opam install camlp5:

Where the whole terminal has been:

EDIT 2 (Solved, repeating)

Suddenly it worked. I wrote once again sudo cpan IPC::System::Simple (there was no questions now) and after that, opam install conf-perl-ipc-system-simple.

Anyway, the Quoation module is not opening for me.