Fatal Error: Segmentation Violation

Cliff Bender <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Hi all,

I'm trying to call my prolog program from C, but am having trouble.
The program itself takes a sentence in English and parses it out into
something like:

sentence(subject(np(det(the),noun(boy))),predicate(vp(intrans_v(gives))))

To do this, in my C program, I call read_line/1 which reads the line
and puts each word in a list that is given as the argument:
[the,boy,gives,'.']

(I found read_line/1 at
http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/read_linepl.txt
and modified it to work with gprolog)

My C code does the following to get that input and copy it to another
PlTerm* called sentence to use as the argument in a later call:
  Pl_Query_Begin(TRUE);
  input[0] = Mk_Variable();
  Pl_Query_Call(Find_Atom("read_line"), 1, input);
  Copy_Term(&sentence[1],input);
  Pl_Query_End(PL_CUT);
  Pl_Query_Begin(TRUE);
  sentence[0] = Mk_String(str); /* sentence[0] = Parse_form */

The prolog predicate c_parse/2 looks like this:
c_parse(Parse_form,Input) :-
         trim_period(Input,I),
         (s(Parse_form,I,[]);comp_s(Parse_form,I,[])).

Parse_form is the result which would look like the output I gave
above. Input is the list. trim_period/2 removes the period at the end
of the list and leaves the result in the term I. s/3 and comp_s/3
parses I and leaves the result in Parse_form.

At this point in the C program, i call
  parsed = Pl_Query_Call(Find_Atom("c_parse"), 2, sentence);
and i get
Fatal Error: Segmentation Violation_#219430624
and the program crashes.

I have no idea what is going on. Can anyone help?

thanks in advance,

CB
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.