开发者

Ocaml Syntax Error

开发者 https://www.devze.com 2022-12-11 07:17 出处:网络
What\'s wrong with this code? I can\'t figure it out: let parent(rules : grammar) (symbol1 : string) (symbol2 : string) : (SymbolSet.t) =

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?

开发者_如何学Python

This is just fine:

let fundementalRule set1 set2 rules =
  allpairs (parent rules) set1 set2;;


maybe the types should be SymbolSet.t instead of SymbolSet


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:

SymbolSet.singleton (getParent [symbol1; symbol2] rules)

I don't have any way to test this code, but I do get an error when I try to run this code:

# let foo arg1 listarg arg2 = ();;
val foo : 'a -> 'b -> 'c -> unit = <fun>
# foo (1 [1; 2] 2);;
Error: This expression is not a function; it cannot be applied

I think that should be this:

SymbolSet.singleton getParent [symbol1; symbol2] rules
0

精彩评论

暂无评论...
验证码 换一张
取 消