Ocaml 语法错误
这段代码有什么问题?我无法弄清楚:
let parent (rules : grammar) (symbol1 : string) (symbol2 : string) : (SymbolSet.t) =
try
SymbolSet.singleton (getParent [symbol1; symbol2] rules)
with
Not_found -> SymbolSet.singleton "";;
let fundementalRule (set1 : SymbolSet) (set2 : SymbolSet) (rules : grammar) : (SymbolSet) =
allpairs (parent rules) set1 set2;;
Characters 20-21:
let fundementalRule (set1 : SymbolSet) (set2 : SymbolSet) (rules : grammar) : (SymbolSet) =
^
Syntax error: ')' expected, the highlighted '(' might be unmatched
括号是匹配的。那么是什么原因导致这个问题呢?
这很好:
let fundementalRule set1 set2 rules =
allpairs (parent rules) set1 set2;;
What's wrong with this code? I can't figure it out:
let parent (rules : grammar) (symbol1 : string) (symbol2 : string) : (SymbolSet.t) =
try
SymbolSet.singleton (getParent [symbol1; symbol2] rules)
with
Not_found -> SymbolSet.singleton "";;
let fundementalRule (set1 : SymbolSet) (set2 : SymbolSet) (rules : grammar) : (SymbolSet) =
allpairs (parent rules) set1 set2;;
Characters 20-21:
let fundementalRule (set1 : SymbolSet) (set2 : SymbolSet) (rules : grammar) : (SymbolSet) =
^
Syntax error: ')' expected, the highlighted '(' might be unmatched
The parenthesis is matched. What then is causing this issue?
This is just fine:
let fundementalRule set1 set2 rules =
allpairs (parent rules) set1 set2;;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许类型应该是
SymbolSet.t
而不是SymbolSet
maybe the types should be
SymbolSet.t
instead ofSymbolSet
上面那行是什么?我敢打赌,在这段代码之前的某个地方有一个不匹配的括号。
更新
我的直觉告诉我错误就在这里:
我没有任何方法来测试此代码,但是当我尝试运行此代码时确实收到错误:
我认为应该是这样的:
What's on the line above it? I'd be willing to bet that there is an unmatched paren somewhere before this code.
Update
My intuition is telling me that the error is here:
I don't have any way to test this code, but I do get an error when I try to run this code:
I think that should be this: