1

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;;
asked Nov 7, 2009 at 21:17

2 Answers 2

1

maybe the types should be SymbolSet.t instead of SymbolSet

answered Nov 8, 2009 at 2:12
Sign up to request clarification or add additional context in comments.

1 Comment

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.
1

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
answered Nov 7, 2009 at 21:24

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.