首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用ocamlfind查找OCaml编译错误

用ocamlfind查找OCaml编译错误
EN

Stack Overflow用户
提问于 2014-04-24 03:33:51
回答 1查看 353关注 0票数 0

以下是代码:

代码语言:javascript
复制
class parser =

let test1 = function
| 1 -> print_int 1
| 2 -> print_int 2
| _ -> print_int 3 in

let test = function
| 1 -> print_int 1
| 2 -> print_int 2
| _ -> print_int 3 in

object(self)

end

这是_tags

代码语言:javascript
复制
true: syntax(camlp4o)
true: package(deriving,deriving.syntax)
true: thread,debug,annot
true: bin_annot

以下是编译命令:

代码语言:javascript
复制
ocamlbuild -use-ocamlfind test.native

以下是编译错误:

代码语言:javascript
复制
Warning: tag "package" does not expect a parameter, but is used with parameter   "deriving,deriving.syntax"
Warning: tag "syntax" does not expect a parameter, but is used with parameter "camlp4o"
+ /usr/local/bin/ocamldep.opt -modules test.ml > test.ml.depends
File "test.ml", line 8, characters 0-3:
Error: Syntax error
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.

但是,当我使用这个时:

代码语言:javascript
复制
ocamlbuild test.native

然后代码就可以被成功编译..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-24 20:00:43

这是因为ocamlbuild -use-ocamlfind test.native指示编译器使用camlp4解析器。它与标准的OCaml解析器略有不同。实际上,parser是camlp4中的关键字,所以不能将它用作类名。改名就行了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23259325

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档