01: package ca.draisey.free.tprolog;
02:
03:
04:
05:
06:
07:
08: final class QuantifiedSentence extends Sentence {
09: QuantifiedSentence( final int n, final QuanTerm t, final Sentence s )
10: {
11: numberofVariables = n;
12: variable = t;
13: sentence = s;
14: }
15:
16:
17: final void listing( final int f, final Variables these, final java.io.PrintWriter p, final Monitor m )
18: {
19: if( f == 0 ) {
20: p.print( "Quantifier( " );
21: variable.listing( f, these, p, m );
22: p.print( ", " );
23: sentence.listing( f, these, p, m );
24: p.print( " )" );
25: }
26: else if( ( f & 1 ) == 0 ) {
27: p.print( "(" );
28: variable.listing( f, these, p, m );
29: p.print( ")" );
30: sentence.listing( f, these, p, m );
31: }
32: else sentence.listing( f, these, p, m );
33: }
34:
35:
36: final void listVariables( final Variables these, final java.io.PrintWriter p, final Monitor m )
37: {
38: sentence.listVariables( these, p, m );
39: listed( these, p, m );
40: p.println();
41: }
42:
43:
44: final boolean hasNextQuantifier() { return true; }
45: final Sentence nextQuantifier() { return sentence; }
46: final void listed( final Variables these, final java.io.PrintWriter p, final Monitor m )
47: {
48: variable.listing( 2, these, p, m );
49: p.print( "=" );
50: variable.listing( 4, these, p, m );
51: }
52:
53:
54:
55: final Variables instantiateVariables()
56: {
57: return new Variables( numberofVariables );
58: }
59:
60: final Clause dequantifyClause() { return sentence.dequantifyClause(); }
61: final Term dequantifyTerm() { return sentence.dequantifyTerm(); }
62:
63:
64: final String getkey() {
65: return sentence.getkey();
66: }
67:
68:
69: private final int numberofVariables;
70: private final QuanTerm variable;
71: private final Sentence sentence;
72: }
73:
74:
Prolog in Java
A trivial prolog interpreter written in java.
Copyright 2004, M.E.J.Draisey
This file is part of tprologinjava.
tprologinjava is free software; you can redistribute it and/or modify it under
the terms of the GNU General
Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
tprologinjava is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with tprologinjava; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Formatted with
GNU source-highlight:
http:// www.gnu.org/ software/ src-highlite