From: Mark Wooding Date: Thu, 26 May 2016 08:26:09 +0000 (+0100) Subject: src/c-types-parse.lisp: Introduce a pluggable parser for declspecs. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/3088c93403f4b8c015ecc6f789248ebef644ddcb?ds=inline;hp=--cc src/c-types-parse.lisp: Introduce a pluggable parser for declspecs. * 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. --- 3088c93403f4b8c015ecc6f789248ebef644ddcb diff --git a/src/c-types-parse.lisp b/src/c-types-parse.lisp index 4475c72..2c0e725 100644 --- a/src/c-types-parse.lisp +++ b/src/c-types-parse.lisp @@ -224,9 +224,13 @@ (defun declspecs-type (specs) (define-indicator :declspec "") -(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)