git.fiddlerwoaroof.com
Browse code

Merge pull request #1 from nakrakiiya/master

ported to more implementations and added support for quicklisp

Brian Guarraci authored on 28/03/2013 19:35:44
Showing 14 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,28 @@
1
+# see http://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
2
+# default
3
+* -text
4
+
5
+# binaries
6
+*.png binary
7
+*.jpg binary
8
+*.exe binary
9
+*.dll binary
10
+*.exe binary
11
+*.7z  binary
12
+*.gz  binary
13
+*.zip binary
14
+
15
+
16
+
17
+
18
+# Standard to msysgit
19
+*.doc	 diff=astextplain
20
+*.DOC	 diff=astextplain
21
+*.docx diff=astextplain
22
+*.DOCX diff=astextplain
23
+*.dot  diff=astextplain
24
+*.DOT  diff=astextplain
25
+*.pdf  diff=astextplain
26
+*.PDF	 diff=astextplain
27
+*.rtf	 diff=astextplain
28
+*.RTF	 diff=astextplain
0 29
new file mode 100644
... ...
@@ -0,0 +1,3 @@
1
+.svn/
2
+*.el~
3
+.project
0 4
\ No newline at end of file
... ...
@@ -12,13 +12,14 @@
12 12
 ;;; Dario Guise, Skef Wholey, Michael Parzen, and Dan Kuokka. 
13 13
 ;;; Modified to work in CLtL1, CLtL2 and X3J13 compatible lisps by 
14 14
 ;;; Mark Kantrowitz on 14-OCT-92. The auto.ops and reactor.ops demo files
15
-;;; were provided by Michael Mauldin.
15
+;;; were provided by Michael Mauldin.  In year 2013, ported to modern Common
16
+;;; Lisp implementations and added support for quicklisp by Xiaofeng Yang.
16 17
 ;;; 
17 18
 ;;; This code is made available is, and without warranty of any kind by the
18 19
 ;;; authors or by Carnegie-Mellon University.
19 20
 ;;;
20
-;;; This code has been tested in Allegro v4.1, Lucid v4.1, IBCL, and
21
-;;; CMU CL.
21
+;;; This code has been tested in Clozure CL v1.9, SBCL v1.0.57, CLISP v2.49,
22
+;;; ECL v12.12.1, ABCL v1.1.1, Lispworks v6.1, MKCL v1.1.3, and Allegro CL v8.2.
22 23
 ;;;
23 24
 ;;; Source code:
24 25
 ;;;    ops.lisp, ops-globals.lisp, ops-backup.lisp, ops-compile.lisp, 
... ...
@@ -38,22 +39,11 @@
38 39
 ;;; ********************************
39 40
 ;;; Usage **************************
40 41
 ;;; ********************************
41
-;;;
42
-;;; Before loading:
43
-;;;    Change the global variable *ops-code-directory* to refer to the
44
-;;;    directory where the OPS5 sources are kept. You may also need to
45
-;;;    change the definition of OPS-PATHNAME depending on your lisp.
46
-;;;
47 42
 ;;; 
48 43
 ;;; To use:
49
-;;;    1. From Lisp, load the file "ops":
50
-;;;          (load "ops")
51
-;;;    2. Go into the OPS package:
52
-;;;          (in-package "OPS")
53
-;;;    3. To compile the OPS sources, use compile-ops:
54
-;;;          (compile-ops)
55
-;;;    4. To load the OPS sources, use load-ops:
56
-;;;          (load-ops)
44
+;;;    1. Clone this project and put into the local-projects directory of quicklisp (e.g. "~/quicklisp/local-projects").
45
+;;;    2. Use quicklisp to load this project:
46
+;;;          (ql:quickload "ops5")
57 47
 ;;; Now you can load your OPS5 code or start typing in productions.
58 48
 ;;; If you want to load in a new set of productions, call (reset-ops)
59 49
 ;;; between rule sets. For a nice REP Loop, run (ops).
... ...
@@ -79,29 +69,25 @@
79 69
 ;;; ********************************
80 70
 ;;; Sample Run *********************
81 71
 ;;; ********************************
82
-> (load "ops")
83
-;;; Loading binary file "ops.hbin"
84
-#P"/afs/andrew.cmu.edu/scs/cs/15-381/ops5v1/ops.hbin"
85
-> (in-package "OPS")
86
-#<Package "OPS" 40242A7E>
87
-> (load-ops)
88
-;;; Loading binary file "/afs/andrew.cmu.edu/scs/cs/15-381/ops5/ops-globals.hbin"
89
-;;; Loading binary file "/afs/andrew.cmu.edu/scs/cs/15-381/ops5/ops-util.hbin"
90
-;;; Loading binary file "/afs/andrew.cmu.edu/scs/cs/15-381/ops5/ops-backup.hbin"
91
-;;; Loading binary file "/afs/andrew.cmu.edu/scs/cs/15-381/ops5/ops-compile.hbin"
92
-;;; Loading binary file "/afs/andrew.cmu.edu/scs/cs/15-381/ops5/ops-main.hbin"
93
-;;; Loading binary file "/afs/andrew.cmu.edu/scs/cs/15-381/ops5/ops-match.hbin"
94
-;;; Loading binary file "/afs/andrew.cmu.edu/scs/cs/15-381/ops5/ops-io.hbin"
95
-;;; Loading binary file "/afs/andrew.cmu.edu/scs/cs/15-381/ops5/ops-rhs.hbin"
96
-NIL
97
-> (load "../ops/auto.ops")
98
-;;; Loading source file "../ops/auto.ops"
99
-;;; Warning: File "../ops/auto.ops" does not begin with IN-PACKAGE.  Loading into package "OPS"
72
+CL-USER> (ql:quickload "ops5")
73
+To load "ops5":
74
+  Load 1 ASDF system:
75
+    ops5
76
+; Loading "ops5"
77
+.........................
78
+("ops5")
79
+CL-USER> (in-package "OPS")
80
+#<Package "OPS">
81
+OPS> (load (merge-pathnames "../demo/auto.ops" *ops-code-directory*))
82
+Resetting OPS5 interpreter: 
83
+             
84
+   deleting productions, working memory, etc.
85
+Common Lisp OPS5 interpreter, version 19-OCT-92.
100 86
 ******************
101
-#P"/afs/andrew.cmu.edu/scs/cs/15-381/ops/auto.ops"
102
-> (make ready)
87
+#P"/home/nakrakiiya/quicklisp/local-projects/ops5/demo/auto.ops"
88
+OPS> (make ready)
103 89
 NIL
104
-> (run)
90
+OPS> (run)
105 91
 
106 92
 
107 93
 Automobile Diagnosis 
... ...
@@ -128,5 +114,5 @@ end -- explicit halt
128 114
   4 mean conflict set size (7 maximum)
129 115
  10 mean token memory size (17 maximum)
130 116
 NIL
131
-> 
117
+OPS> 
132 118
 ;;; *EOF*
133 119
new file mode 100644
... ...
@@ -0,0 +1,51 @@
1
+;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
2
+
3
+(in-package :asdf)
4
+
5
+;; #-(or openmcl mcl sbcl cmu scl clisp lispworks ecl allegro cormanlisp abcl)
6
+;; (error "Sorry, this Lisp is not yet supported.  Patches welcome!")
7
+
8
+(defsystem :ops5
9
+  :version "19-OCT-92"
10
+  :description "VPS2 -- Interpreter for OPS5
11
+
12
+This Common Lisp version of OPS5 is in the public domain.  It is based
13
+in part on based on a Franz Lisp implementation done by Charles L. Forgy
14
+at Carnegie-Mellon University, which was placed in the public domain by
15
+the author in accordance with CMU policies.  Ported to Common Lisp by 
16
+George Wood and Jim Kowalski. CMU Common Lisp modifications by
17
+Dario Guise, Skef Wholey, Michael Parzen, and Dan Kuokka. 
18
+Modified to work in CLtL1, CLtL2 and X3J13 compatible lisps by 
19
+Mark Kantrowitz on 14-OCT-92. The auto.ops and reactor.ops demo files
20
+were provided by Michael Mauldin. In year 2013, ported to modern Common
21
+Lisp implementations and added support for quicklisp by Xiaofeng Yang.
22
+
23
+This code is made available is, and without warranty of any kind by the
24
+authors or by Carnegie-Mellon University.
25
+
26
+Documentation for OPS may be found in the OPS5 User's Manual, July 1981,
27
+by Forgy, CMU CSD.
28
+
29
+This version of OPS5 was obtained by anonymous ftp from 
30
+   ftp.cs.cmu.edu:/user/ai/areas/expert/systems/ops5/ops5_cl.tgz
31
+"
32
+  :author ""
33
+  :maintainer ""
34
+  :licence "public domain"
35
+  :depends-on ()
36
+  :components
37
+  ((:module "src"
38
+            :serial t
39
+            :components
40
+            (
41
+             (:file "ops")			; so that shadowing takes place...
42
+             (:file "ops-globals")
43
+             (:file "ops-util")		; macros
44
+             (:file "ops-compile")
45
+             (:file "ops-rhs")		; defines macros used in ops-init
46
+             (:file "ops-main")		; macros
47
+             (:file "ops-match") 
48
+             (:file "ops-backup")
49
+             (:file "ops-io")
50
+             (:file "ops-init")))))
51
+             
0 52
similarity index 97%
1 53
rename from ops-backup.lisp
2 54
rename to src/ops-backup.lisp
... ...
@@ -21,12 +21,12 @@
21 21
 
22 22
 ;;; Internal Global Variables
23 23
 
24
-(defvar *refracts*)
25
-(defvar *record*)
26
-(defvar *record-array*)
27
-(defvar *recording*)
28
-(defvar *max-record-index*)
29
-(defvar *record-index*)
24
+(defvar *refracts* nil)
25
+(defvar *record* nil)
26
+(defvar *record-array* nil)
27
+(defvar *recording* nil)
28
+(defvar *max-record-index* nil)
29
+(defvar *record-index* nil)
30 30
 
31 31
 
32 32
 
33 33
similarity index 98%
34 34
rename from ops-compile.lisp
35 35
rename to src/ops-compile.lisp
... ...
@@ -23,27 +23,27 @@
23 23
 
24 24
 ;;; External global variables
25 25
 
26
-(defvar *real-cnt*)
27
-(defvar *virtual-cnt*)
28
-(defvar *last-node*)
29
-(defvar *first-node*)
30
-(defvar *pcount*)
26
+(defvar *real-cnt* nil)
27
+(defvar *virtual-cnt* nil)
28
+(defvar *last-node* nil)
29
+(defvar *first-node* nil)
30
+(defvar *pcount* nil)
31 31
 
32 32
 
33 33
 ;;; Internal global variables
34 34
 
35
-(defvar *matrix*)
36
-(defvar *curcond*)
37
-(defvar *feature-count*)
38
-(defvar *ce-count*)
39
-(defvar *vars*)
40
-(defvar *ce-vars*)
41
-(defvar *rhs-bound-vars*)
42
-(defvar *rhs-bound-ce-vars*)
43
-(defvar *last-branch*)
44
-(defvar *subnum*)
45
-(defvar *cur-vars*)
46
-(defvar *action-type*)
35
+(defvar *matrix* nil)
36
+(defvar *curcond* nil)
37
+(defvar *feature-count* nil)
38
+(defvar *ce-count* nil)
39
+(defvar *vars* nil)
40
+(defvar *ce-vars* nil)
41
+(defvar *rhs-bound-vars* nil)
42
+(defvar *rhs-bound-ce-vars* nil)
43
+(defvar *last-branch* nil)
44
+(defvar *subnum* nil)
45
+(defvar *cur-vars* nil)
46
+(defvar *action-type* nil)
47 47
 
48 48
 
49 49
 
50 50
similarity index 94%
51 51
rename from ops-globals.lisp
52 52
rename to src/ops-globals.lisp
... ...
@@ -18,11 +18,11 @@
18 18
 
19 19
 ;;; Global variables also used by OPS modules.
20 20
 
21
-(defvar *halt-flag*)
22
-(defvar *cycle-count*)
23
-(defvar *p-name*)
24
-(defvar *ptrace*)
25
-(defvar *wtrace*)
21
+(defvar *halt-flag* nil)
22
+(defvar *cycle-count* nil)
23
+(defvar *p-name* nil)
24
+(defvar *ptrace* nil)
25
+(defvar *wtrace* nil)
26 26
 
27 27
 ;;; Hash Tables.
28 28
 
29 29
similarity index 97%
30 30
rename from ops-init.lisp
31 31
rename to src/ops-init.lisp
... ...
@@ -44,7 +44,7 @@
44 44
   "Clears the state of OPS to allow a new rule set to be loaded."
45 45
 
46 46
   ;; Tell the user what we're doing.
47
-  (format t "~&Resetting OPS5 interpreter: ~
47
+  (format t "~&Resetting OPS5 interpreter: 
48 48
              ~&   deleting productions, working memory, etc.")
49 49
   (remove *)
50 50
   (ops-init)
51 51
similarity index 99%
52 52
rename from ops-io.lisp
53 53
rename to src/ops-io.lisp
... ...
@@ -22,11 +22,11 @@
22 22
 
23 23
 ;;; Internal global variables.
24 24
 
25
-(defvar *write-file*)
26
-(defvar *trace-file*)
27
-(defvar *accept-file*)
28
-(defvar *ppline*)
29
-(defvar *filters*)
25
+(defvar *write-file* nil)
26
+(defvar *trace-file* nil)
27
+(defvar *accept-file* nil)
28
+(defvar *ppline* nil)
29
+(defvar *filters* nil)
30 30
 
31 31
 
32 32
 
33 33
similarity index 98%
34 34
rename from ops-main.lisp
35 35
rename to src/ops-main.lisp
... ...
@@ -24,21 +24,21 @@
24 24
 
25 25
 ;;; Global variables used in this module only.
26 26
 
27
-(defvar *limit-token*)
28
-(defvar *total-wm*)
29
-(defvar *max-token*)
30
-(defvar *total-token*)
31
-(defvar *brkpts*)
32
-(defvar *phase*)
33
-(defvar *break-flag*)
34
-(defvar *remaining-cycles*)
35
-(defvar *conflict-set*)
36
-(defvar *max-cs*)
37
-(defvar *total-cs*)
38
-(defvar *limit-cs*)
39
-(defvar *strategy*)
40
-(defvar *class-list*)
41
-(defvar *buckets*)
27
+(defvar *limit-token* nil)
28
+(defvar *total-wm* nil)
29
+(defvar *max-token* nil)
30
+(defvar *total-token* nil)
31
+(defvar *brkpts* nil)
32
+(defvar *phase* nil)
33
+(defvar *break-flag* nil)
34
+(defvar *remaining-cycles* nil)
35
+(defvar *conflict-set* nil)
36
+(defvar *max-cs* nil)
37
+(defvar *total-cs* nil)
38
+(defvar *limit-cs* nil)
39
+(defvar *strategy* nil)
40
+(defvar *class-list* nil)
41
+(defvar *buckets* nil)
42 42
 
43 43
 
44 44
 
45 45
similarity index 98%
46 46
rename from ops-match.lisp
47 47
rename to src/ops-match.lisp
... ...
@@ -23,17 +23,17 @@
23 23
 
24 24
 ;;; External global variables
25 25
 
26
-(defvar *current-token*)
26
+(defvar *current-token* nil)
27 27
 
28 28
 
29 29
 ;;; Internal global variables
30 30
 
31
-(defvar *alpha-data-part*)
32
-(defvar *alpha-flag-part*)
33
-(defvar *flag-part*)
34
-(defvar *data-part*)
35
-(defvar *sendtocall*)
36
-(defvar *side*)
31
+(defvar *alpha-data-part* nil)
32
+(defvar *alpha-flag-part* nil)
33
+(defvar *flag-part* nil)
34
+(defvar *data-part* nil)
35
+(defvar *sendtocall* nil)
36
+(defvar *side* nil)
37 37
 (proclaim '(special *c1* *c2* *c3* *c4* *c5* *c6* *c7* *c8* *c9*
38 38
 	   *c10* *c11* *c12* *c13* *c14* *c15* *c16* *c17* *c18* *c19*
39 39
 	   *c20* *c21* *c22* *c23* *c24* *c25* *c26* *c27* *c28* *c29*
40 40
similarity index 97%
41 41
rename from ops-rhs.lisp
42 42
rename to src/ops-rhs.lisp
... ...
@@ -24,29 +24,29 @@
24 24
 
25 25
 ;;; External global variables
26 26
 
27
-(defvar *size-result-array*)
28
-(defvar *in-rhs*)
29
-(defvar *current-wm*)
30
-(defvar *max-wm*)
31
-(defvar *action-count*)
32
-(defvar *critical*)
27
+(defvar *size-result-array* nil)
28
+(defvar *in-rhs* nil)
29
+(defvar *current-wm* nil)
30
+(defvar *max-wm* nil)
31
+(defvar *action-count* nil)
32
+(defvar *critical* nil)
33 33
 
34 34
 
35 35
 ;;; Internal global variables
36 36
 
37
-(defvar *wmpart-list*)
38
-(defvar *wm-filter*)
39
-(defvar *wm*)
40
-(defvar *old-wm*)
41
-(defvar *result-array*)
42
-(defvar *variable-memory*)
43
-(defvar *last*)
44
-(defvar *max-index*)
45
-(defvar *next-index*)
46
-(defvar *data-matched*)
47
-(defvar *ce-variable-memory*)
48
-(defvar *rest*)
49
-(defvar *build-trace*)
37
+(defvar *wmpart-list* nil)
38
+(defvar *wm-filter* nil)
39
+(defvar *wm* nil)
40
+(defvar *old-wm* nil)
41
+(defvar *result-array* nil)
42
+(defvar *variable-memory* nil)
43
+(defvar *last* nil)
44
+(defvar *max-index* nil)
45
+(defvar *next-index* nil)
46
+(defvar *data-matched* nil)
47
+(defvar *ce-variable-memory* nil)
48
+(defvar *rest* nil)
49
+(defvar *build-trace* nil)
50 50
 
51 51
 
52 52
 ;;;; Functions for RHS evaluation
53 53
similarity index 100%
54 54
rename from ops-util.lisp
55 55
rename to src/ops-util.lisp
56 56
similarity index 68%
57 57
rename from ops.lisp
58 58
rename to src/ops.lisp
... ...
@@ -43,47 +43,9 @@
43 43
 ;;; Source Directory ***************
44 44
 ;;; ********************************
45 45
 
46
-(defparameter *ops-code-directory* ""
47
-  "Directory where OPS5 source code is stored.")
48
-
49
-(defun ops-pathname (filename)
50
-  (concatenate 'string *ops-code-directory* filename))
51
-
52
-(defun load-ops-file (filename)
53
-  (load (ops-pathname filename)))
54
-
55
-(defun compile-load (filename)
56
-  (let ((pname (ops-pathname filename)))
57
-    (compile-file (concatenate 'string pname ".lisp"))
58
-    (load pname)))
59
-
60
-;;; ********************************
61
-;;; OPS Loading, Compilation, Init *
62
-;;; ********************************
63
-
64
-(defun load-ops ()
65
-  (load-ops-file "ops-globals")
66
-  (load-ops-file "ops-util")
67
-  (load-ops-file "ops-backup")
68
-  (load-ops-file "ops-compile")
69
-  (load-ops-file "ops-main")
70
-  (load-ops-file "ops-match")
71
-  (load-ops-file "ops-io")
72
-  (load-ops-file "ops-rhs")
73
-  (load-ops-file "ops-init")
74
-  (ops-init))
75
-
76
-(defun compile-ops ()
77
-  (load-ops-file "ops")			; so that shadowing takes place...
78
-  (compile-load "ops-globals")
79
-  (compile-load "ops-util")		; macros
80
-  (compile-load "ops-compile")
81
-  (compile-load "ops-rhs")		; defines macros used in ops-init
82
-  (compile-load "ops-main")		; macros
83
-  (compile-load "ops-match") 
84
-  (compile-load "ops-backup")
85
-  (compile-load "ops-io")
86
-  (compile-load "ops-init"))
46
+(defparameter *ops-code-directory* #.(or *compile-file-pathname*
47
+                                         *load-pathname*)
48
+              "Directory where OPS5 source code is stored.")
87 49
 
88 50
 ;;; ********************************
89 51
 ;;; REP Loop ***********************