I was trying to make an overload of function that I have created on GF, but after using the overload function I keep getting this error message.
Am I using this function of GF incorrectly or is there is any new update to this functionality.
Here is what I was trying to do
Sentence = sentence(mkN(“random”));
oper
sentence:overload {
sentence:N-> Utt =
\noun->
mkUtt(mkNP(noun));
sentence:V-> Utt =
\ verb->
mkutt(mkImp(mkV2(verb)));
};
Thank you~
There are a lot of things wrong in this sample. First of all, it seems like you have written it in a word processor instead of a text editor, because the characters are not what they are supposed to be. For instance, :
is the real colon, and your code snippet has :
, which is a different Unicode codepoint. Look at them side by side:
:: -- first the wrong one, followed by the correct one
:: -- The wrong colon includes more space
:: -- the right colon is thicker and less space
The solution to this problem is to program in a text editor (like Atom or Sublime) or a programming IDE (like VS code), not in a word processor. Many editors don't have a syntax highlighting for GF, but you can see in this video how to use Haskell mode instead.
Now let's suppose we fixed the characters, then we have this.
sentence : overload {
sentence : N -> Utt =
\noun -> mkUtt (mkNP noun) ;
sentence : V -> Utt =
\verb -> mkUtt something_NP ; -- the original had an unrelated bug
} ;
Now we get the error you describe. The solution is to change the first :
to a =
, like this:
sentence = overload { -- = used to be :
{- sentence : N -> Utt = -- the rest unchanged
\noun -> mkUtt (mkNP noun) ;
sentence : V -> Utt =
\verb -> mkUtt something_NP ; -- the original had an unrelated bug
} ; -}
As Paula said, your example is just fragments. Here's a minimal fully working version.
abstract Sentences = {
cat
S ;
fun
Sentence : S ;
}
And here's a concrete, with all the weird Unicode characters swapped out for actual characters. I also fixed the mkImp
instance for V2
: if you see here in the synopsis, there's no mkImp
instance for a single V2
, it's either V
or V2
and NP
.
concrete SentencesEng of Sentences = open SyntaxEng, ParadigmsEng in {
lincat
S = Utt ;
lin
Sentence = sentence (mkN "random") ;
oper
sentence = overload {
sentence : N -> Utt =
\noun -> mkUtt (mkNP noun) ;
sentence : V -> Utt =
\verb -> mkUtt (mkImp (mkV2 verb) something_NP) ;
} ;
}