-
Notifications
You must be signed in to change notification settings - Fork 0
/
clast-defclass-elements.lisp
91 lines (59 loc) · 2.29 KB
/
clast-defclass-elements.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
;;;; -*- Mode: Lisp -*-
;;;; clast-defclass-elements.lisp --
;;;; Definitions of the DEFCLASS "subforms" necessary for parsing of
;;;; "defclass" constructs.
;;;; See the file COPYING for copyright and license information.
;;;; Notes:
;;;; 2024-06-19 MA:
;;;; Factored out of 'parse-defclass' to improve code dependencies.
(in-package "CLAST")
;;;;===========================================================================
;;;; Prologue.
;;;;
;;;; Parsing DEFCLASS is not as complicated as parsing DEFSTRUCT but
;;;; it still requires some hairy code.
;;;;
;;;; As per LOOP two kinds of sub-forms are defined to deal with slots
;;;; and options.
;;;----------------------------------------------------------------------------
;;; defclass-subform
;;; class-option-subform, class-slot-subform, class-slot-option-subform
(defclass defclass-subform (form) ())
(defclass class-slot-subform (defclass-subform)
((name :reader class-slot-subform-name
:initarg :slot-name) ; Inherited; new reader and initarg added.
(options :reader class-slot-subform-options
:initarg :slot-options)
)
)
(defun is-class-slot-subform (x)
(typep x 'class-slot-subform))
(defun class-slot-subform-p (x)
(is-class-slot-subform x))
(defmethod clast-element-subforms ((sos class-slot-subform))
(list (class-slot-subform-name sos)
(class-slot-subform-options sos)
))
(defclass class-option-subform (defclass-subform)
((name :reader class-option-subform-name
:initarg :option-name) ; Inherited; new reader and initarg added.
(spec :reader class-option-subform-spec
:initarg :option-spec)
)
)
(defun is-class-option-subform (x)
(typep x 'class-option-subform))
(defun class-option-subform-p (x)
(is-class-option-subform x))
(defun make-class-option-form (option-name &rest spec)
(make-instance 'class-option-subform
:option-name option-name
:option-spec spec))
(defmethod clast-element-subforms ((sos class-option-subform))
(list (class-option-subform-name sos)
(class-option-subform-spec sos)))
(defmethod clast-element-subforms ((df defclass-form))
(list* (defclass-form-name df)
(defclass-form-options df)
(defclass-form-slots df)))
;;;; end of file -- clast-defclass-elements.lisp --