1 /*
2 * #%L
3 * prolobjectlink-jpi-jtrolog
4 * %%
5 * Copyright (C) 2012 - 2018 WorkLogic Project
6 * %%
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation, either version 2.1 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Lesser Public License for more details.
16 *
17 * You should have received a copy of the GNU General Lesser Public
18 * License along with this program. If not, see
19 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
20 * #L%
21 */
22 package jTrolog.terms;
23
24 import java.util.Iterator;
25 import java.util.LinkedList;
26
27 /**
28 * Term class - root prolog data type
29 *
30 * @see jTrolog.terms.Struct
31 * @see Var
32 * @see jTrolog.terms.Number
33 * @author ivar.orstavik@hist.no
34 */
35 @SuppressWarnings({ "rawtypes", "serial" })
36 public abstract class Term implements java.io.Serializable {
37
38 public int type;
39
40 public final static int VAR = 1;
41 public final static int NUMBER = 2;
42 public final static int STRUCT = 3;
43 public final static int ATOM = 4;
44
45 // important atoms to be used only once
46 public static final Term TRUE = new StructAtom("true".intern());
47 public static final Term FALSE = new StructAtom("false".intern());
48 public static final StructAtom emptyList = new StructAtom("[]");
49 public static final Iterator iterator = new LinkedList().iterator();
50
51 // Tree data Jens Teubner prepost style:
52 // http://www-db.in.tum.de/~grust/teaching/ws0506/XML-DB/db-supp-xml-pdf
53 // page 17
54 public int pos = 0;
55
56 public Term[] tree;
57 public int[] prePost;
58
59 protected Term() {
60 tree = new Term[] { this };
61 prePost = new int[] { 0 };
62 }
63
64 public abstract String toStringSmall();
65 }