diff options
author | Shawn O. Pearce <sop@google.com> | 2011-06-17 08:56:33 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2011-06-17 09:49:04 -0700 |
commit | 34233caaa8b64af5534ac01e269ed1671d40fb1f (patch) | |
tree | a2cb0777a85e5acc96734bd37fa1938a44732518 | |
parent | 18c64c86c81029ee9aeb34a474f9f0e3820c0b91 (diff) | |
download | prolog-cafe-34233caaa8b64af5534ac01e269ed1671d40fb1f.tar.gz |
Remove Serializable from internals
A Java ClassLoader is not Serializable. Therefore we cannot
also make the PrologClassLoader Serializable.
We don't really need to serialize an interpreter, so also
throw away any support for that.
-rw-r--r-- | src/lang/BlockingPrologControl.java | 4 | ||||
-rw-r--r-- | src/lang/InternalDatabase.java | 3 | ||||
-rw-r--r-- | src/lang/Operation.java | 4 | ||||
-rw-r--r-- | src/lang/OutOfLoop.java | 3 | ||||
-rw-r--r-- | src/lang/OutOfScope.java | 3 | ||||
-rw-r--r-- | src/lang/PrologClassLoader.java | 3 | ||||
-rw-r--r-- | src/lang/PrologException.java | 3 | ||||
-rw-r--r-- | src/lang/Term.java | 3 | ||||
-rw-r--r-- | src/lang/Token.java | 2 | ||||
-rw-r--r-- | src/lang/Token.java.bak | 414 | ||||
-rw-r--r-- | src/lang/Trail.java | 1 |
11 files changed, 9 insertions, 434 deletions
diff --git a/src/lang/BlockingPrologControl.java b/src/lang/BlockingPrologControl.java index 5c3a242..e788982 100644 --- a/src/lang/BlockingPrologControl.java +++ b/src/lang/BlockingPrologControl.java @@ -1,7 +1,5 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; - /** * Prolog thread.<br> * The <code>BlockingPrologControl</code> class is an implementation of @@ -99,7 +97,7 @@ import java.io.Serializable; */ public class BlockingPrologControl extends PrologControl - implements Runnable, Serializable { + implements Runnable { /** A volatile instance variable holding a thread. */ private volatile Thread thread; diff --git a/src/lang/InternalDatabase.java b/src/lang/InternalDatabase.java index c0b1bc7..0de54be 100644 --- a/src/lang/InternalDatabase.java +++ b/src/lang/InternalDatabase.java @@ -1,5 +1,4 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; import java.util.LinkedList; /** * Internal database for dynamic predicates.<br> @@ -8,7 +7,7 @@ import java.util.LinkedList; * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) * @version 1.1 */ -public class InternalDatabase implements Serializable { +public class InternalDatabase { protected static final int DEFAULT_SIZE = 100000; /** Maximum size of enties. Initial size is <code>100000</code>. */ diff --git a/src/lang/Operation.java b/src/lang/Operation.java index 458698c..3495b6b 100644 --- a/src/lang/Operation.java +++ b/src/lang/Operation.java @@ -1,7 +1,5 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; - /** * Superclass any single step operation in the Prolog interpreter. * <p> @@ -12,7 +10,7 @@ import java.io.Serializable; * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) * @version 1.0 */ -public abstract class Operation implements Serializable { +public abstract class Operation { /** * Executes this operation and returns a continuation goal. * diff --git a/src/lang/OutOfLoop.java b/src/lang/OutOfLoop.java index d9d6689..bb6c123 100644 --- a/src/lang/OutOfLoop.java +++ b/src/lang/OutOfLoop.java @@ -1,5 +1,4 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; /** * A trail entry for out-of-loop flag.<br> * This <code>OutOfLoop</code> class is used in @@ -10,7 +9,7 @@ import java.io.Serializable; * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) * @version 1.0 */ -public class OutOfLoop implements Serializable,Undoable { +public class OutOfLoop implements Undoable { BlockPredicate p; public OutOfLoop(BlockPredicate _p) { diff --git a/src/lang/OutOfScope.java b/src/lang/OutOfScope.java index 5edf778..9c18100 100644 --- a/src/lang/OutOfScope.java +++ b/src/lang/OutOfScope.java @@ -1,5 +1,4 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; /** * A trail entry for out-of-scope flag.<br> * This <code>OutOfScope</code> class is used in @@ -10,7 +9,7 @@ import java.io.Serializable; * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) * @version 1.0 */ -public class OutOfScope implements Serializable,Undoable { +public class OutOfScope implements Undoable { BlockPredicate p; public OutOfScope(BlockPredicate _p) { diff --git a/src/lang/PrologClassLoader.java b/src/lang/PrologClassLoader.java index 6f407a9..d2b0330 100644 --- a/src/lang/PrologClassLoader.java +++ b/src/lang/PrologClassLoader.java @@ -1,5 +1,4 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; import java.lang.reflect.Constructor; /** * Prolog class loader. @@ -8,7 +7,7 @@ import java.lang.reflect.Constructor; * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) * @version 1.1 */ -public class PrologClassLoader extends ClassLoader implements Serializable { +public class PrologClassLoader extends ClassLoader { /** Initialize using the {@link ClassLoader#getSystemClassLoader()}. */ public PrologClassLoader() { } diff --git a/src/lang/PrologException.java b/src/lang/PrologException.java index 98ca075..0af28c5 100644 --- a/src/lang/PrologException.java +++ b/src/lang/PrologException.java @@ -1,5 +1,4 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; /** * The superclass of classes for Prolog exceptions.<br> * @@ -7,7 +6,7 @@ import java.io.Serializable; * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) * @version 1.0 */ -public abstract class PrologException extends RuntimeException implements Serializable { +public abstract class PrologException extends RuntimeException { /** Constructs a new Prolog exception. */ public PrologException() {} diff --git a/src/lang/Term.java b/src/lang/Term.java index 0c45e00..824acf0 100644 --- a/src/lang/Term.java +++ b/src/lang/Term.java @@ -1,5 +1,4 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; /** * The superclass of classes for term structures. * The subclasses of <code>Term</code> must override @@ -9,7 +8,7 @@ import java.io.Serializable; * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) * @version 1.0 */ -public abstract class Term implements Serializable,Comparable<Term> { +public abstract class Term implements Comparable<Term> { /** Holds an integer value <code>0</code>. */ public static final int EQUAL = 0; diff --git a/src/lang/Token.java b/src/lang/Token.java index 7fd3d07..4fabdb7 100644 --- a/src/lang/Token.java +++ b/src/lang/Token.java @@ -10,7 +10,7 @@ import java.io.*; * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) * @version 1.2.5 */ -public class Token implements Serializable { +public class Token { public static boolean isSolo(int c) { return (c =='!' || c ==';'); diff --git a/src/lang/Token.java.bak b/src/lang/Token.java.bak deleted file mode 100644 index 03455ff..0000000 --- a/src/lang/Token.java.bak +++ /dev/null @@ -1,414 +0,0 @@ -package com.googlecode.prolog_cafe.lang; -import java.util.*; -import java.io.*; -/** - * The <code>Token</code> class contains methods - * for character input/output.<br> - * <font color="red">This document is under construction.</font> - * - * @author Mutsunori Banbara (banbara@kobe-u.ac.jp) - * @author Naoyuki Tamura (tamura@kobe-u.ac.jp) - * @version 1.2 - */ -public class Token implements Serializable { - - public static boolean isSolo(int c) { - return (c =='!' || c ==';'); - } - - public static boolean isSymbol(int c) { - switch (c) { - case '+': - case '-': - case '*': - case '/': - case '\\': - case '^': - case '<': - case '>': - case '=': - case '`': - case '~': - case ':': - case '.': - case '?': - case '@': - case '#': - case '$': - case '&': - return true; - default: - return false; - } - } - - /* - public static int read_token(StringBuffer s, PushbackReader in) - - This method reads one token from the input "in", sets the string, - and returns the token type. - - Type String - -2 "error message" - -1 "end_of_file" - '.' "." full stop - ' ' " " space or comment or unknown chars - ',' "," - '(' "(" - ')' ")" - '[' "[" - ']' "]" - '{' "{" - '}' "}" - ',' "," - '|' "|" - 'I' "decimal" positive integer - 'D' "decimal" positive double - 'A' "atom name" - 'V' "variable name" - 'S' "string" - */ - public static int read_token(StringBuffer s, PushbackReader in) - throws IOException { - - int c, c1; - int rc; - - c = in.read(); // get 1st. char - if(c == -1) { - s.append("end_of_file"); - return -1; - } - if (Character.isDigit((char)c)) { - rc = read_number(c, s, in); - if (rc == 1) - rc = 'I'; - else if (rc == 2) - rc = 'D'; - return rc; - } - if (Character.isLowerCase((char)c)) { - rc = read_word(c, s, in); - if (rc > 0) - rc = 'A'; - return rc; - } - if (Character.isUpperCase((char) c) || c == '_') { - rc = read_word(c, s, in); - if (rc > 0) - rc = 'V'; - return rc; - } - switch (c) { - case '(': - case ')': - case '[': - case ']': - case '{': - case '}': - case ',': - case '|': - s.append((char)c); - return c; - case '.': /* full stop or symbol */ - c1 = in.read(); - if (c1 == -1 || c1 <= ' ') { - s.append("."); - return '.'; - } - in.unread(c1); - break; - case '%': /* one line comment */ - s.append(" "); - while ((c1 = in.read()) != '\n') { - if (c1 == -1) - return ' '; - } - return ' '; - case '/': /* start of comment or symbol */ - if ((c1 = in.read()) == '*') { - s.append(" "); - while (true) { - while ((c1 = in.read()) != '*') { - if(c1 == -1) { - s.append("unexpected end_of_file"); - return -2; - } - } - if ((c1 = in.read()) == '/') - return ' '; - in.unread(c1); - } - } - in.unread(c1); - break; - case '\'': - rc = read_quoted(c, s, in); - if (rc > 0) - rc = 'A'; - return rc; - case '"': - rc = read_quoted(c, s, in); - if (rc > 0) - rc = 'S'; - return rc; - default: - break; - } - if (isSolo(c)) { - s.append((char)c); - return 'A'; - } - if (isSymbol(c)) { - rc = read_symbol(c, s, in); - if (rc > 0) - rc = 'A'; - return rc; - } - s.append(" "); - return ' '; - } - - public static int read_number(int c, StringBuffer s, PushbackReader in) - throws IOException { - - int c1, c2; - in.unread(c); - for (;;) { - c1 = in.read(); - if (! Character.isDigit((char)c1)) - break; - s.append((char) c1); - } - if (c1 != '.'){ - in.unread(c1); - return 1; - } - c2 = in.read(); - if (! Character.isDigit((char)c2)){ - in.unread(c2); - in.unread(c1); - return 1; - } - s.append((char)c1); - in.unread(c2); - for (;;) { - c1 = in.read(); - if (! Character.isDigit((char) c1)) - break; - s.append((char) c1); - } - in.unread(c1); - return 2; - } - - public static int read_word(int c, StringBuffer s, PushbackReader in) - throws IOException { - int c1; - - in.unread(c); - for (;;) { - c1 = in.read(); - if (! Character.isLetterOrDigit((char)c1) && c1 != '_') - break; - s.append((char)c1); - } - in.unread(c1); - return 1; - } - - public static int read_quoted(int quote, StringBuffer s, PushbackReader in) - throws IOException { - int rc; - int c1; - - for (;;) { - c1 = in.read(); - if (c1 == -1 || c1 == '\n') { - in.unread(c1); - return -2; - } else if (c1 == quote){ - c1 = in.read(); - if (c1 != quote) { - in.unread(c1); - return 1; - } - c1 = quote; - } - else if (c1 == '\\') { - rc = escapeSequences(c1, s, in); - if (rc > 0) - continue; - else - return -2; - } - s.append((char)c1); - } - } - - public static int escapeSequences(int backslash, StringBuffer s, PushbackReader in) - throws IOException { - - int c; - c = in.read(); - switch (c) { - case 'b': // backspace - s.append((char) 8); break; - case 't': // horizontal tab - s.append((char) 9); break; - case 'n': // newline - s.append((char)10); break; - case 'v': // vertical tab - s.append((char)11); break; - case 'f': // form feed - s.append((char)12); break; - case 'r': // carriage return - s.append((char)13); break; - case 'e': // escape - s.append((char)27); break; - case 'd': // delete - s.append((char)127); break; - case 'a': // alarm - s.append((char)7); break; - default: - s.append((char)c); - return 2; - } - return 1; - } - - - public static int read_symbol(int c, StringBuffer s, PushbackReader in) - throws IOException { - int c1; - s.append((char)c); - // in.unread(c); - for (;;) { - c1 = in.read(); - if (! isSymbol(c1)) - break; - s.append((char)c1); - } - in.unread(c1); - return 1; - } - - - /* Write */ - public static void write_string(String s, PrintWriter out) { - out.print(s); - } - - public static void writeq_string(String s, PrintWriter out) { - char[] ch; - - ch = s.toCharArray(); - if ((getStringType(s) == 3)){ - out.print("\'"); - for (int i=0; i<ch.length; i++) { - if (ch[i] == '\'') - out.print("\\\'"); - else if (ch[i] == '\\') - out.print("\\\\"); - else if (ch[i] == 8) // backspace - out.print("\\b"); - else if (ch[i] == 9) // horizontal tab - out.print("\\t"); - else if (ch[i] == 10) // newline - out.print("\\n"); - else if (ch[i] == 11) // vertical tab - out.print("\\v"); - else if (ch[i] == 12) // form feed - out.print("\\f"); - else if (ch[i] == 13) // carriage return - out.print("\\r"); - else if (ch[i] == 27) // escape - out.print("\\e"); - else if (ch[i] == 127) // delete - out.print("\\d"); - else if (ch[i] == 7) // alarm - out.print("\\a"); - else - out.print(ch[i]); - } - out.print("\'"); - } else { - write_string(s, out); - } - } - - public static String toQuotedString(String s) { - StringBuffer quoted = new StringBuffer(s.length() * 2); - char[] ch; - - ch = s.toCharArray(); - if ((getStringType(s) == 3)){ - quoted.append("\'"); - for (int i=0; i<ch.length; i++) { - if (ch[i] == '\'') - quoted.append("\\\'"); - else if (ch[i] == '\\') - quoted.append("\\\\"); - else if (ch[i] == 8) // backspace - quoted.append("\\b"); - else if (ch[i] == 9) // horizontal tab - quoted.append("\\t"); - else if (ch[i] == 10) // newline - quoted.append("\\n"); - else if (ch[i] == 11) // vertical tab - quoted.append("\\v"); - else if (ch[i] == 12) // form feed - quoted.append("\\f"); - else if (ch[i] == 13) // carriage return - quoted.append("\\r"); - else if (ch[i] == 27) // escape - quoted.append("\\e"); - else if (ch[i] == 127) // delete - quoted.append("\\d"); - else if (ch[i] == 7) // alarm - quoted.append("\\a"); - else - quoted.append(ch[i]); - } - quoted.append("\'"); - return quoted.toString(); - } else { - return s; - } - } - - - /* - * return value: - * 0 : if string is a lower case alphnum - * 1 : if string is a symbol - * 2 : if string is a solo - * 3 : others - */ - public static int getStringType(String s) { - char[] p; - - if (s.equals("[]") || s.equals("{}")) - return 0; - if (s.equals("") || s.equals(".")) - return 3; - if (s.equals("!") || s.equals(";")) - return 2; - p = s.toCharArray(); // string --> chars[] - if (Character.isLowerCase(p[0])){ - for (int i=1; i<p.length; i++){ - if (! Character.isLetterOrDigit(p[i]) && ((int)p[i]) != '_') - return 3; - } - return 0; - } - if (isSymbol((int) p[0])){ - for (int i=1; i<p.length; i++){ - if (! isSymbol((int) p[i])) - return 3; - } - return 1; - } - return 3; - } -} diff --git a/src/lang/Trail.java b/src/lang/Trail.java index 2b6fcd0..686d750 100644 --- a/src/lang/Trail.java +++ b/src/lang/Trail.java @@ -1,5 +1,4 @@ package com.googlecode.prolog_cafe.lang; -import java.io.Serializable; /** * Trail stack.<br> * The class <code>Trail</code> represents a trail stack.<br> |