chiark / gitweb /
src/c-types-parse.lisp: Introduce a pluggable parser for declspecs.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 29 May 2016 14:08:43 +0000 (15:08 +0100)
  * Rename `scan-declspec' to `scan-simple-declspec'.

  * Have `scan-and-merge-declspec' try the new pluggable parser
    `complex-declspec' before giving up and trying the simple version.

  * Have `parse-declarator' use the correct name when picking out
    qualifiers.

src/c-types-parse.lisp

index 4475c720d179862cf77c46f61cf7003faeabae78..2c0e725731f2b12ff643cb8356868092512dc5b2 100644 (file)
@@ -224,9 +224,13 @@ (defun declspecs-type (specs)
 
 (define-indicator :declspec "<declaration-specifier>")
 
-(defun scan-declspec
+(defun scan-simple-declspec
     (scanner &key (predicate (constantly t)) (indicator :declspec))
-  "Scan a `declspec' from SCANNER.
+  "Scan a simple `declspec' from SCANNER.
+
+   Simple declspecs are the ones defined in the `*declspec-map*' or
+   `*module-type-map*'.  This covers the remaining possibilities if the
+   `complex-declspec' pluggable parser didn't find anything to match.
 
    If PREDICATE is provided then only succeed if (funcall PREDICATE DECLSPEC)
    is true, where DECLSPEC is the raw declaration specifier or C-type object,
@@ -266,7 +270,9 @@ (defun scan-and-merge-declspec (scanner specs)
    SPECS."
 
   (with-parser-context (token-scanner-context :scanner scanner)
-    (if-parse (:consumedp consumedp) (scan-declspec scanner)
+    (if-parse (:consumedp consumedp)
+             (or (plug complex-declspec scanner)
+                 (scan-simple-declspec scanner))
       (aif (combine-declspec specs it)
           (values it t consumedp)
           (values (list :declspec) nil consumedp)))))
@@ -329,7 +335,7 @@ (defun parse-declarator (scanner base-type &key kernel abstractp)
 
                 (parse
                   (seq ((quals (list ()
-                                 (scan-declspec
+                                 (scan-simple-declspec
                                   scanner
                                   :indicator :qualifier
                                   :predicate (lambda (ds)