Logtalk 2.15.2 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@812 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura
2003-04-02 13:57:50 +00:00
parent 8509b82b18
commit f1b417f1c3
103 changed files with 744 additions and 100 deletions

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
@@ -41,6 +41,9 @@ bricks
classvars
example of implementation of class variables (as found in Smalltalk)
dcgs
example of using DCG rules inside objects and categories
dynpred
example of using some of the built-in database handling methods

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -0,0 +1,13 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
To load all entities in this example consult the dcgs.loader
utility file (note that this is a Prolog file).
This folder contains examples of using DCGs inside objects and
categories.

View File

@@ -0,0 +1,35 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
% DCG rules implementing a simple calculator:
| ?- calculator::parse("1+2-3*4", Result).
Result = -9
yes
% recognizing gramatically correct sentences
| ?- sentence::parse([the, girl, likes, the, boy], Result).
Result = true
yes
| ?- sentence::parse([the, girl, scares, the, boy], Result).
Result = false
yes
% generating parse trees for sentences
| ?- parsetree::parse([the, girl, likes, the, boy], Tree).
Tree = Tree = s(np(d(the), n(girl)), vp(v(likes), np(d(the), n(boy))))
yes

View File

@@ -0,0 +1,23 @@
:- object(calculator,
implements(parsep)).
parse(Expression, Value) :-
phrase(expr(Value), Expression).
expr(Z) --> term(X), "+", expr(Y), {Z is X + Y}.
expr(Z) --> term(X), "-", expr(Y), {Z is X - Y}.
expr(X) --> term(X).
term(Z) --> number(X), "*", term(Y), {Z is X * Y}.
term(Z) --> number(X), "/", term(Y), {Z is X / Y}.
term(Z) --> number(Z).
number(C) --> "+", number(C).
number(C) --> "-", number(X), {C is -X}.
number(X) --> [C], {0'0 =< C, C =< 0'9, X is C - 0'0}.
:- end_object.

View File

@@ -0,0 +1,10 @@
:- initialization(
logtalk_load([
parsep,
calculator,
parsetree,
determiners,
nouns,
verbs,
sentence])).

View File

@@ -0,0 +1,9 @@
:- category(determiners).
determiner --> [the].
determiner --> [a].
:- end_category.

View File

@@ -0,0 +1,9 @@
:- category(nouns).
noun --> [boy].
noun --> [girl].
:- end_category.

View File

@@ -0,0 +1,20 @@
:- protocol(parsep).
:- info([
version is 1.0,
date is 2003/3/17,
author is 'Paulo Moura',
comment is 'Parse protocol for using DCG rules.']).
:- public(parse/2).
:- mode(parse(?list, ?nonvar), zero_or_more).
:- info(parse/2, [
comment is 'Parses a list using the defined set of DCG rules.',
argnames is ['List', 'Result']]).
:- end_protocol.

View File

@@ -0,0 +1,29 @@
:- object(parsetree,
implements(parsep)).
parse(List, Tree) :-
phrase(sentence(Tree), List).
sentence(s(NP,VP)) --> noun_phrase(NP), verb_phrase(VP).
noun_phrase(np(D,NP)) --> determiner(D), noun(NP).
noun_phrase(NP) --> noun(NP).
verb_phrase(vp(V)) --> verb(V).
verb_phrase(vp(V,NP)) --> verb(V), noun_phrase(NP).
determiner(d(the)) --> [the].
determiner(d(a)) --> [a].
noun(n(boy)) --> [boy].
noun(n(girl)) --> [girl].
verb(v(likes)) --> [likes].
verb(v(hates)) --> [hates].
:- end_object.

View File

@@ -0,0 +1,22 @@
:- object(sentence,
implements(parsep),
imports(determiners, nouns, verbs)).
parse(List, true) :-
phrase(sentence, List).
parse(_, false).
sentence --> noun_phrase, verb_phrase.
noun_phrase --> ::determiner, ::noun.
noun_phrase --> ::noun.
verb_phrase --> ::verb.
verb_phrase --> ::verb, noun_phrase.
:- end_object.

View File

@@ -0,0 +1,9 @@
:- category(verbs).
verb --> [likes].
verb --> [hates].
:- end_category.

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Release 2.15.2
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================