01: package ca.draisey.free.tprolog;
02:
03:
04:
05:
06:
07:
08:
09:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24: final class QuanTerm extends VariTerm {
25: QuanTerm( final String n, final int i )
26: {
27: super( i );
28: name = n;
29: }
30:
31:
32: final void listing( final int f, final Variables these, final java.io.PrintWriter p, final Monitor m )
33: {
34: switch( f & 6 ) {
35: case 2:
36: p.print( name );
37: return;
38: case 4:
39: if( these.ruleBindings[ index ] == null ) {
40: p.print( "_" + these.hashCode() + "_" + index );
41: }
42: else {
43: these.ruleBindings[ index ].listing( f, these.instanceBindings[ index ], p, m );
44: }
45: return;
46: case 6:
47: if( these.ruleBindings[ index ] == null ) {
48: p.print( name + " = _" + these.hashCode() + "_" + index );
49: }
50: else {
51: these.ruleBindings[ index ].listing( f, these.instanceBindings[ index ], p, m );
52: }
53: return;
54: default:
55: if( these.ruleBindings[ index ] == null ) {
56: p.print( "QuanTerm( " + name + " = _" + these.hashCode() + "_" + index + " )" );
57: }
58: else {
59: p.print( "QuanTerm( " + name + "=" );
60: these.ruleBindings[ index ].listing( f, these.instanceBindings[ index ], p, m );
61: p.print( " )" );
62: }
63: return;
64: }
65: }
66:
67:
68: final int instantiationIndex()
69: {
70: return index;
71: }
72:
73:
74: private final String name;
75: }
76:
77:
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