我试图使用funset_avltree
库,但编译器生成无效的C代码。我正在使用ATS/Postiats 0.2.10版。如何使用funset_avltree库?
我的代码是相当简单:
(* ast.sats *)
staload "libats/SATS/funset_avltree.sats"
datatype ast =
| ast_var of string
fun free_vars (ast : ast) :<> set string
(* ast.dats *)
#include "share/atspre_staload.hats"
staload "./ast.sats"
staload "libats/SATS/funset_avltree.sats"
dynload "libats/DATS/funset_avltree.dats"
implement free_vars (ast : ast) : set string =
case+ ast of
| ast_var name => funset_sing name
编译器的输出,但是,相当混乱:
ast_dats.c:359:51: warning: implicit declaration of function 'S2EVar' is invalid in C99 [-Wimplicit-function-declaration] ATSINSmove(tmpret0, PMVtmpltcstmat[0](funset_sing<S2EVar(4713)>)(tmp1)) ; ^ ast_dats.c:359:39: error: use of undeclared identifier 'funset_sing' ATSINSmove(tmpret0, PMVtmpltcstmat[0](funset_sing<S2EVar(4713)>)(tmp1)) ; ^ ast_dats.c:359:64: error: expected expression ATSINSmove(tmpret0, PMVtmpltcstmat[0](funset_sing<S2EVar(4713)>)(tmp1)) ; ^
我得到类似的错误与funset
和funset_listord
。我必须错过一些微不足道的东西。我是否需要包含某些内容或将某个标记传递给编译器?
嗨,谢谢。我不知道你必须使用模板定义来调整dat文件。在“ATS编程简介”一书中我找不到这个。 – rightfold
不客气。模板系统是相当新的。我认为作者还在完成相关章节。 –
@rightfold,我访问了你的网站。您保存有关ATS的文档真的很棒。我只想提请你注意http://discourse.ats-lang.org/c/documentation是官方的,并且计划包括越来越多的用户提供的文档。你的贡献非常受欢迎。谢谢。 –