chiark / gitweb /
src/pset-*.lisp: Allow parsing and retrieval of C types as property values.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 17 Nov 2015 17:16:19 +0000 (17:16 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 17 Nov 2015 20:33:52 +0000 (20:33 +0000)
Hack src/sod.asd.in because pset now depends on c-types.

src/pset-impl.lisp
src/pset-parse.lisp
src/pset-proto.lisp
src/sod.asd.in

index e3e505f65cebae34b14d3943871ac5dd7b4cfbed..14cb43b9a3f5dbe3dc5773fd30a36e7d6f36042d 100644 (file)
@@ -65,6 +65,14 @@ (defmethod coerce-property-value
     ((value symbol) (type (eql :symbol)) (wanted (eql :id)))
   (frob-identifier (symbol-name value)))
 
+;;; Types.
+
+(defmethod coerce-property-value
+    ((value string) (type (eql :id)) (wanted (eql :type)))
+  (or (gethash value *module-type-map*)
+      (gethash value *declspec-map*)
+      (error "Unknown type `~A'." value)))
+
 ;;;--------------------------------------------------------------------------
 ;;; Property sets.
 
index 6b91696800a84d859d2f4b821aea963e9b453f25..ddc34e04f96eed91c43ed700ff10b3ae7a9a766c 100644 (file)
@@ -83,7 +83,7 @@     (defun parse-expression (scanner)
    term: factor | term `*' factor | term `/' factor
    factor: primary | `+' factor | `-' factor
    primary: int | id | string | `(' expression `)' | `{' fragment `}'
-     | `?' lisp-expression
+     | `<' declspec+ declarator[empty] `>' | `?' lisp-expression
 
    Only operators for dealing with integers are provided."
       (with-parser-context (token-scanner-context :scanner scanner)
@@ -107,6 +107,17 @@     (defun parse-expression (scanner)
                                          (parse-delimited-fragment scanner
                                                                    #\{ #\}))
                                          t t))
+                          (#\<
+                           (parse (seq (#\<
+                                        (ds (parse-c-type scanner))
+                                        (dc (parse-declarator
+                                             scanner ds
+                                             :kernel (lambda ()
+                                                       (values nil t nil))
+                                             :abstractp t))
+                                        #\>)
+                                    (values (cons :type (car dc))
+                                            t t))))
                           (t
                            (values (list :int :id :char :string #\?)
                                    nil nil)))))
index eaf3a7732e08d7d7c90b738ed2d7448d369598b9..e16e04c39c5a1f01a6b85ef11caf26de0442eb48 100644 (file)
@@ -55,11 +55,11 @@ (defstruct (property
    distinctly about identifiers, strings and symbols, and we've only got two
    obvious Lisp types to play with.  Sad, but true."
 
-  (name nil :type (or string symbol))
-  (value nil :type t)
-  (%type nil :type symbol)
-  (location (file-location nil) :type file-location)
-  (key nil :type symbol)
+  (name nil :type (or string symbol) :read-only t)
+  (value nil :type t :read-only t)
+  (%type nil :type symbol :read-only t)
+  (location (file-location nil) :type file-location :read-only t)
+  (key nil :type symbol :read-only t)
   (seenp nil :type boolean))
 (define-access-wrapper p-type p-%type :read-only t)
 
@@ -72,7 +72,8 @@ (defgeneric decode-property (raw)
   (:method ((raw character)) (values :char raw))
   (:method ((raw property)) (values (p-type raw) (p-value raw)))
   (:method ((raw cons)) (values (car raw) (cdr raw)))
-  (:method ((raw function)) (values :func raw)))
+  (:method ((raw function)) (values :func raw))
+  (:method ((raw c-type)) (values :type raw)))
 
 (export 'make-property)
 (defun make-property (name raw-value &key type location seenp)
index d5ab15cff423aed59006249bc69256340dc61192..2cb2e8e59f034186dd8dbbfb283525481b247b42 100644 (file)
          ("c-types-proto" "c-types-class-impl" "fragment-parse"))
 
    ;; Property set protocol.
-   (:file "pset-proto" :depends-on ("package"))
+   (:file "pset-proto" :depends-on ("package" "c-types-proto"))
    (:file "pset-impl" :depends-on ("pset-proto"))
    (:file "pset-parse" :depends-on ("pset-proto" "lexer-proto"))