views:

186

answers:

2

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;;
+1  A: 

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
Jason Baker
added line above it
Rosarch
+1  A: 

maybe the types should be SymbolSet.t instead of SymbolSet

newacct
`SymbolSet` by itself is not a valid type expression; the message from the Ocaml compiler is incorrect, this is because it uses the "error" mechanism of ocamlyacc (and yacc) to guess what the error may be.
Bruno De Fraine