NAME
Prolog Interpreter alpha 0.02
SYNOPSIS
Language::Prolog::Interpreter->readFile('E:/src/PROLOG/flamenco.pr');
or
$a = <<'EOPROLOG';
parent(john,sally).
parent(john,joe).
parent(mary,joe).
parent(phil,beau).
parent(jane,john).
grandparent(X,Z) :-parent(X,Y),parent(Y,Z).
EOPROLOG
;
while ($a) {
	eval 'Language::Prolog::Interpreter->readStatement(\$a)';
	$@ && die $@,$a,"\n";
	$a=~s/^\s*//;
}
# Above is same as
# eval 'Language::Prolog::Interpreter->readFile($pathtomyfile)';
$a = '?- grandparent(GPARENT,GCHILD).';
print $a,"\n";
$Q = Language::Prolog::Interpreter->readStatement(\$a);
while($Q->query()) {
	print "found solutions\n";
	print 'GPARENT = ',$Q->variableResult('GPARENT'),"\n";
	print 'GCHILD = ',$Q->variableResult('GCHILD'),"\n\n";
}
print "no more solutions\n\n";
$a = 'member(A,[A|_]).';
$b = 'member(A,[_|B]) :- member(A,B).'; #Classic member
Language::Prolog::Interpreter->readStatement(\$a);
Language::Prolog::Interpreter->readStatement(\$b);
$a = '?- member(c(V),[a(a),b(b),c(c),d(d),c(q)]).';
print $a,"\n";
$Q = Language::Prolog::Interpreter->readStatement(\$a);
while($Q->query()) {
	print "found solutions\n";
	print 'V = ',$Q->variableResult('V'),"\n\n";
}
print "no more solutions\n\n";
DESCRIPTION
A simple interpreter which doesn't allow infix operators (except for :- and ,, both of which are built in).
SYNTAX
There are three possible statements:
- 1. Clauses
 - 
A single clause ending in a statement terminator (
.).This gets added to the database.
 - 2. Rules
 - 
A single rule ending in a statement terminator (
.).This gets added to the store.
 - 3. Queries
 - 
The he query characters
?-, followed by a comma separated list of clauses, ending in a statement terminator (.).This creates and returns a query.
 - Comments
 - 
Multi-line comments are Java-like, taking the form
/** ... **/.Single-line/end-of-line comments are donnated by
%. - Whitespace
 - 
Whitespace is ignored everywhere except in single quoted atoms
 
TERMS
Terms are:-
- Lists1:
 - 
Comma separated lists of terms enclosed in square brackets
e.g [Term1,Term2] - Lists2:
 - 
As List1, but final term is a variable separated by a '|'
e.g [Term1,Term2|Variable] - Atoms1:
 - 
sequence of characters/digits/underscore (i.e
\wcharacter class) starting with a lower case character.e.g. this_Is_An_Atom - Atoms1:
 - 
any sequence of characters enclosed in single quotes (')
e.g. 'This is another atom!' - Variables:
 - 
sequence of characters/digits/underscore (i.e
\wcharacter class) starting with an upper case character or underscoree.g. This_is_a_var, _and_this, _90 - Clauses:
 - 
an Atom1 immediately followed by a left bracket,
(, followed by a comma separated list of terms, terminating in a right bracket.e.g clause(one), clause2(a,hello,'More !',[a,b,c]) - Rules:
 - 
A Clause, followed by optional whitespace, followed by
:-, followed by optional whitespace, followed by a list of clauses separated by commas. 
AUTHOR
Jack Shirazi.
Since Mr Shirzai seems to have vanished, updated by Lee Goddard <lgoddard@cpan.org> to support file parsing, single- and multi-line comments, and multi-ilne clauses.
COPYRIGHT
Copyright (C) 1995, Jack Shirazi. All Rights Reserved.
Updates Copyright (C) 2001, Lee Goddard. All Rights Reserved.
Usage is under the same terms as for Perl itself.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 145:
 '=item' outside of any '=over'
- Around line 362:
 You forgot a '=back' before '=head1'