2017-01-27 33 views
0

我使用graphviz根据很多人给我的建议,但我遇到了一个问题。我想使用Format.moduleocaml中写一个点,并且我有一个记录,其中有五个字段定义了一个自动机,其中包括由列表int*char*int表示的转换以及由int列表表示的最终状态。第一个字段是一个int的初始状态。我还定义了一个函数成员,它接受一个参数并测试它是否是给定列表的成员。我该怎么做,以便我可以编写一个完整的点来识别初始状态,并用节点[shape = point]start ; start -> x来表示它,并用圆圈表示最终状态,用双环来表示它们。我想这样做,但我遇到了问题,当我编译它,它说如何绘制一个自动机图?

File "automatagraphicstest1.ml", line 44, characters 22-37: Error: This expression has type automate -> Format.formatter -> int * char * int -> unit but an expression was expected of type Format.formatter -> 'a -> unit Type automate is not compatible with type Format.formatter

+0

请为您的代码使用pastebin。编辑器的屏幕截图不可用。 – Drup

+0

http://pastebin.com/QK5qxEhd –

+0

http://pastebin.com/5NSb7qFU这是另一个尝试我想要什么,如果你看看它,你可能明白我想在这里做什么 –

回答

0

要解决你的类型的错误,只是这种替换fmt_transitions功能:

let fmt_transitions fmt auto = 
    Format.fprintf fmt "@[<v 2>digraph output {@,%[email protected],@]}@,@." 
    (Format.pp_print_list (fmt_transition1 auto)) auto.transitions 

你的问题是pp_print_list预期类型为Format.formatter -> 'a -> unit。您的函数fmt_automaton1将自动机作为额外的第一个参数,所以我们需要先部分应用它,然后我们才能提供转换列表。

+0

我明白了,但我需要测试一个inedge是否是我们在记录中的int作为初始状态:etat_initial然后我们必须做node [shape = point] start;开始 - > inedge;并且如果outedge如果属于列表etats_finaux则是最终状态,那么它应该是节点[shape = doublecircle] outedge; [shape = circle]; inedge-> outedge [label ='by']; –

+0

和形状的圆到所有常规的转换,但问题出在fmt –

+0

fmt_transitions *它只需要一个列表,我不知道用什么来逃避字符串 –