gpt4 book ai didi

syntax - let..in中的OCaml语法错误

转载 作者:行者123 更新时间:2023-12-03 08:05:11 25 4
gpt4 key购买 nike

我是Ocaml的新手,正在尝试打印AST树,但是in函数的mon_to_string出现语法错误。
注意:已定义所有使用的功能。

let rec print exp =
let rec the_exp tree out = match tree with
[] -> out

and exp_to_string tree = match tree with
| Ast.Expression.Identifier(x) -> print_identifier x
| Ast.Expression.Literal(x) -> print_literal x
| Ast.Expression.BinaryExp(x) -> print_bin_exp x
| Ast.Expression.UnaryExp(x) -> print_unary_exp x
in "<Expression>\n" ^ exp_to_string exp ^ "</Expression>\n"

and mon_to_string tree = match tree with
| Ast.Monitor.ExpressionGuard(x) -> print_exp_guard x
| Ast.Monitor.QuantifiedGuard(x) -> print_quant_guard x
| Ast.Monitor.Conditional(x) -> print_conditional x
| Ast.Monitor.Evaluate(x) -> print_eval x
| Ast.Monitor.Choice(x) -> print_choice x
in "<Monitor>" ^ "\n" ^ mon_to_string exp ^ "</Monitor>\n"

最佳答案

没有与最后一个let对应的in

正确的语法如下所示:

let rec v1 = exp1
and v2 = exp2
and v3 = exp3
in exp4

你有:
let rec v1 = exp1
and v2 = exp2
in exp3
and v3 = exp4
in exp5

关于syntax - let..in中的OCaml语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48796370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com