Does anybody know a library (preferably not SWI-prolog) for using Prolog in Xcode? If not, do you know a library for a more recent language that does a similar job?
Thanks
Does anybody know a library (preferably not SWI-prolog) for using Prolog in Xcode? If not, do you know a library for a more recent language that does a similar job?
Thanks
I have been using GNU Prolog (gprolog) a lot lately and it has a beautifully simple interface to C which allows you to produce custom executables made of standard code plus your own.
Being a Cocoa programmer too I am not sure how you would integrate the code but section "10.6 Calling Prolog from C" might give you some ideas on hoe to use it as part of an Xcode application.
The next section, 10.7 Defining a new C main() function might help on how you could translate that code (shown here for clarity) into something more ObjC like:
static int
Main_Wrapper(int argc, char *argv[])
{
int nb_user_directive;
PlBool top_level;
nb_user_directive = Pl_Start_Prolog(argc, argv);
top_level = Pl_Try_Execute_Top_Level();
Pl_Stop_Prolog();
if (top_level || nb_user_directive)
return 0;
fprintf(stderr,
"Warning: no initial goal executed\n"
" use a directive :- initialization(Goal)\n"
" or remove the link option --no-top-level"
" (or --min-bips or --min-size)\n");
return 1;
}
int
main(int argc, char *argv[])
{
return Main_Wrapper(argc, argv);
}
Kludging all that into NSApplicationMain
is going to be fun and interesting!
The only other way I could think of doing it is to make the above code start your Cocoa application maybe by using objc_msgSend
as described in this answer, "Calling Cocoa APIs from C".
Best of luck with it. Sean.