The `argument-list' parser is now less monolithic: the work of parsing
individual arguments is given to new functions `arg-decl' and
`argument'.
Also, the interface between `argument-list' and its parent
`postfix-lparen' is changed. Instead of simply returning its argument
list, `argument-list' now returns a function which can be applied to a
base type to produce the appropriate function type.
None of this changes any externally observable behaviour.
(parse (seq ((name (funcall kernel-parser)))
(cons #'identity name))))
(parse (seq ((name (funcall kernel-parser)))
(cons #'identity name))))
+ (arg-decl (abstractp)
+ (parse (seq ((base-type (parse-c-type scanner))
+ (dtor (parse-declarator scanner base-type
+ :abstractp abstractp)))
+ dtor)))
+
+ (argument ()
+ ;; argument ::= type abstract-declspec
+
+ (parse (seq ((dtor (arg-decl t)))
+ (make-argument (cdr dtor) (car dtor)))))
+
- ;; [argument [`,' argument]* [`,' `...']] | `...'
+ ;; argument-list ::=
+ ;; [argument [`,' argument]* [`,' argument-tail]]
+ ;; | argument-tail
+ ;;
+ ;; argument-tail ::= `...'
;;
;; The possibility of a trailing `,' `...' means that we
;; can't use the standard `list' parser. Note that, unlike
;;
;; The possibility of a trailing `,' `...' means that we
;; can't use the standard `list' parser. Note that, unlike
(scanner-step scanner)
(return))
(multiple-value-bind (arg winp consumedp)
(scanner-step scanner)
(return))
(multiple-value-bind (arg winp consumedp)
- (parse (seq ((base-type (parse-c-type scanner))
- (dtor (parse-declarator scanner
- base-type
- :abstractp t)))
- (make-argument (cdr dtor) (car dtor))))
(unless winp
(if (or consumedp args)
(return-from argument-list (values arg nil t))
(unless winp
(if (or consumedp args)
(return-from argument-list (values arg nil t))
(unless (eq (token-type scanner) #\,)
(return))
(scanner-step scanner))
(unless (eq (token-type scanner) #\,)
(return))
(scanner-step scanner))
- (values (nreverse args) t args)))
+ (values (let ((rargs (nreverse args)))
+ (lambda (ret)
+ (make-function-type ret rargs)))
+ t
+ args)))
(postfix-lparen ()
;; Postfix: `(' argument-list `)'
(postfix-lparen ()
;; Postfix: `(' argument-list `)'
- (parse (seq (#\( (args (argument-list)) #\))
+ (parse (seq (#\( (make (argument-list)) #\))
(postop "()" (state 10)
(cons (lambda (type)
(funcall (car state)
(postop "()" (state 10)
(cons (lambda (type)
(funcall (car state)
- (make-function-type type args)))
(cdr state))))))
(dimension ()
(cdr state))))))
(dimension ()