Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Parse defpattern #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions quickdocs-parser.asd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:homepage ""
:bug-tracker ""
:source-control (:git "")
:depends-on (:optima :trivia)
:components ((:module "src"
:serial t
:components
Expand Down
8 changes: 8 additions & 0 deletions src/nodes.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@
()
(:documentation "A type."))

(defclass optima-pattern-node (operator-node)
()
(:documentation "An optima defpattern node."))

(defclass trivia-pattern-node (operator-node)
()
(:documentation "A trivia defpattern node."))

;;; CFFI classes

(defclass cffi-node ()
Expand Down
4 changes: 3 additions & 1 deletion src/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
:struct-node
:class-node
:condition-node
:type-node)
:type-node
:optima-pattern-node
:trivia-pattern-node)
;; CFFI classes
(:export :cffi-node
:cffi-function
Expand Down
18 changes: 18 additions & 0 deletions src/parsers.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@
:docstring docstring
:lambda-list lambda-list)))

(define-parser optima:defpattern (name lambda-list &rest body)
(let ((docstring (if (stringp (first body))
(first body)
nil)))
(make-instance 'optima-pattern-node
:name name
:docstring docstring
:lambda-list lambda-list)))

(define-parser trivia:defpattern (name lambda-list &rest body)
(let ((docstring (if (stringp (first body))
(first body)
nil)))
(make-instance 'trivia-pattern-node
:name name
:docstring docstring
:lambda-list lambda-list)))

(defun parse-slot (slot)
(if (listp slot)
(let ((slot (copy-list slot)))
Expand Down
10 changes: 10 additions & 0 deletions src/print.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
(print-unreadable-object (type stream)
(format stream "type ~A" (render-humanize (node-name type)))))

(defmethod print-object ((optima-pattern optima-pattern-node) stream)
"Print a optima-pattern definition node."
(print-unreadable-object (optima-pattern stream)
(format stream "optima-pattern ~A" (render-humanize (node-name optima-pattern)))))

(defmethod print-object ((trivia-pattern trivia-pattern-node) stream)
"Print a trivia-pattern definition node."
(print-unreadable-object (trivia-pattern stream)
(format stream "trivia-pattern ~A" (render-humanize (node-name trivia-pattern)))))

;;; CFFI classes

(defmethod print-object ((function cffi-function) stream)
Expand Down