X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/8293b90a8f027ed9b7e4ebb566f67e5c783864c9..8922d11064c215cdd8b6288985cc6d2e573826c2:/src/c-types-parse.lisp diff --git a/src/c-types-parse.lisp b/src/c-types-parse.lisp index e0cfc88..b398ca9 100644 --- a/src/c-types-parse.lisp +++ b/src/c-types-parse.lisp @@ -336,13 +336,18 @@ (make-pointer-type type quals))) (cdr state)))))) - (next-declspec-p () - ;; Ansert whether the next token is a valid declaration - ;; specifier, without consuming it. - (and (eq (token-type scanner) :id) - (let ((id (token-value scanner))) - (or (gethash id *module-type-map*) - (gethash id *declspec-map*))))) + (predict-argument-list-p () + ;; See `prefix-lparen'. Predict an argument list rather + ;; than a nested declarator if (a) abstract declarators are + ;; permitted and (b) the next token is a declaration + ;; specifier or ellipsis. + (let ((type (token-type scanner)) + (value (token-value scanner))) + (and abstractp + (or (eq type :ellipsis) + (and (eq type :id) + (or (gethash value *module-type-map*) + (gethash value *declspec-map*))))))) (prefix-lparen () ;; Prefix: `(' @@ -357,7 +362,7 @@ ;; specifier, then we have a postfix argument list. (parse (peek (seq (#\( - (nil (if (and abstractp (next-declspec-p)) + (nil (if (predict-argument-list-p) (values nil nil nil) (values t t nil)))) (lparen #\)))))) @@ -367,7 +372,7 @@ (cons #'identity name)))) (argument-list () - ;; [ argument [ `,' argument ]* [ `,' `...' ] ] | `...' + ;; [argument [`,' argument]* [`,' `...']] | `...' ;; ;; The possibility of a trailing `,' `...' means that we ;; can't use the standard `list' parser. Note that, unlike