;;; Type names.
(define-pluggable-parser module typename (scanner pset)
- ;; `typename' id ( `,' id )* `;'
+ ;; `typename' list[id] `;'
(declare (ignore pset))
(with-parser-context (token-scanner-context :scanner scanner)
(parse (and "typename"
- (skip-many (:min 1)
- (seq ((id :id))
- (if (gethash id *module-type-map*)
- (cerror* "Type `~A' already defined" id)
- (add-to-module *module*
- (make-instance 'type-item
- :name id))))
+ (skip-many ()
+ (error ()
+ (seq ((id :id))
+ (if (or (gethash id *module-type-map*)
+ (find-simple-c-type id))
+ (cerror* "Type `~A' already defined" id)
+ (add-to-module *module*
+ (make-instance 'type-item
+ :name id))))
+ (skip-until () #\, #\;))
#\,)
- #\;))))
+ (must #\;)))))
;;; Fragments.
(define-pluggable-parser module code (scanner pset)
;; `code' id `:' item-name [constraints] `{' c-fragment `}'
;;
- ;; constrains ::= `[' constraint-list `]'
+ ;; constraints ::= `[' list[constraint] `]'
;; constraint ::= item-name+
;; item-name ::= id | `(' id+ `)'
(declare (ignore pset))
(seq (#\( (names (list (:min 1) (kw))) #\))
names)))))
(parse (seq ("code"
- (reason (kw))
- #\:
- (name (item))
+ (reason (must (kw)))
+ (nil (must #\:))
+ (name (must (item)))
(constraints (? (seq (#\[
- (constraints (list (:min 1)
- (list (:min 1)
- (item))
- #\,))
+ (constraints
+ (list ()
+ (list (:min 1)
+ (error (:ignore-unconsumed t)
+ (item)
+ (skip-until ()
+ :id #\( #\, #\])))
+ #\,))
#\])
constraints)))
(fragment (parse-delimited-fragment scanner #\{ #\})))
- (add-to-module *module*
- (make-instance 'code-fragment-item
- :fragment fragment
- :constraints constraints
- :reason reason
- :name name)))))))
+ (when name
+ (add-to-module *module*
+ (make-instance 'code-fragment-item
+ :fragment fragment
+ :constraints constraints
+ :reason reason
+ :name name))))))))
;;; External files.
(let* ((*readtable* (copy-readtable))
(*package* (find-package '#:sod-user))
(char-scanner (make-instance 'charbuf-scanner
- :stream f-stream))
+ :stream f-stream
+ :filename (namestring pathname)))
(scanner (make-instance 'sod-token-scanner
:char-scanner char-scanner)))
(with-default-error-location (scanner)
(parse (skip-many ()
(seq ((pset (parse-property-set scanner))
(nil (error ()
- (plug module scanner pset))))
+ (plug module scanner pset)
+ (skip-until (:keep-end nil)
+ #\; #\}))))
(check-unused-properties pset))))
(declare (ignore consumedp))
(unless winp (syntax-error scanner result)))))))))
;;; Setting properties.
(define-pluggable-parser module set (scanner pset)
- ;; `set' property-list `;'
+ ;; `set' list[property] `;'
(with-parser-context (token-scanner-context :scanner scanner)
(parse (and "set"
(lisp (let ((module-pset (module-pset *module*)))
:location (p-location prop))
(setf (p-seenp prop) t))
pset))
- (parse (skip-many (:min 0)
+ (parse (skip-many (:min (if pset 0 1))
(error (:ignore-unconsumed t)
(parse-property scanner module-pset)
- (skip-until (:keep-end t) #\, #\;))
+ (skip-until () #\, #\;))
#\,))))
#\;))))
(funcall make class frag pset scanner)))))
(define-pluggable-parser class-item initargs (scanner class pset)
- ;; initarg-item ::= `initarg' declspec+ init-declarator-list
+ ;; initarg-item ::= `initarg' declspec+ list[init-declarator]
;; init-declarator ::= declarator [`=' initializer]
(with-parser-context (token-scanner-context :scanner scanner)
(parse (seq ("initarg"
(parse-slot-item (sub-pset base-type type name)
;; slot-item ::=
;; declspec+ declarator -!- [initializer]
- ;; [`,' init-declarator-list] `;'
+ ;; [`,' list[init-declarator]] `;'
;;
- ;; init-declarator-list ::=
- ;; declarator [initializer] [`,' init-declarator-list]
+ ;; init-declarator ::= declarator [initializer]
(parse (and (seq ((init (? (parse-initializer))))
(make-sod-slot class name type
sub-pset scanner)
(parse-initializer-item (sub-pset must-init-p constructor)
;; initializer-item ::=
- ;; [`class'] -!- slot-initializer-list `;'
+ ;; [`class'] -!- list[slot-initializer] `;'
;;
;; slot-initializer ::= id `.' id [initializer]
(let ((parse-init (if must-init-p #'parse-initializer
;; definition; otherwise it might be a message or slot.
(cond ((not (typep type 'c-function-type))
(when (consp name)
- (cerror*-with-location
- scanner
+ (cerror*
"Method declarations must have function type")
(setf name (cdr name)))
(parse-slot-item sub-pset base-type type name))
(add-to-module *module* class))))))))
(define-pluggable-parser module class (scanner pset)
- ;; `class' id `:' id-list class-body
+ ;; `class' id `:' list[id] class-body
;; `class' id `;'
(with-parser-context (token-scanner-context :scanner scanner)
(parse (seq ("class"