diff options
author | colin <colin@cicadas.surf> | 2023-08-02 21:01:03 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-08-02 21:01:03 -0700 |
commit | 5800a49934ab75be17f03af8c9a2243120a97339 (patch) | |
tree | 86c5f02f0dcc2c884f5a1dddeac8b22675f23e94 /argot.lisp | |
parent | 483867e966e5b009be1892cc3f81de0b5885ba17 (diff) |
Add docgen
Diffstat (limited to 'argot.lisp')
-rw-r--r-- | argot.lisp | 41 |
1 files changed, 26 insertions, 15 deletions
@@ -118,21 +118,32 @@ and it returns VAR in that case." :lhs ',lhs :pattern ',pattern ,@(expand-functional-argument :check lhs bindings check vars) - ,@(expand-functional-argument :action lhs bindings action vars))))) - `(progn - (defvar ,name nil) - (setf ,name (make-instance 'grammar - :documentation ,documentation - :start-rule ',(first (first ruledefs)))) - ,@(loop - :for ruledef :in ruledefs - :for (lhs pattern vars check action) := (handler-case (parse-rule-def ruledef) - (invalid-rule-def (e) (invoke-debugger e))) - :for bindings := (collect-let-bindings lhs vars) - :collect (rule-includer name lhs pattern check action bindings vars)) - - (defmacro ,name (&body tokens) - (argot:parse ,name tokens)))))) + ,@(expand-functional-argument :action lhs bindings action vars))))) + (let* ((parsed-rules + (loop :for ruledef :in ruledefs + :collect (handler-case (parse-rule-def ruledef) + (invalid-rule-def (e) (invoke-debugger e))))) + (rule-adder-forms + (loop :for (lhs pattern vars check action) :in parsed-rules + :for bindings := (collect-let-bindings lhs vars) + :collect (rule-includer name lhs pattern check action bindings vars))) + (docstring + (with-output-to-string (*standard-output*) + (princ documentation) + (terpri) (terpri) + (loop :for (lhs pattern . more) :in parsed-rules + :do (write-rule-doc lhs pattern) + (terpri))))) + `(progn + (defvar ,name nil) + (setf ,name (make-instance 'grammar + :documentation ,documentation + :start-rule ',(first (first ruledefs)))) + ,@rule-adder-forms + + (defmacro ,name (&body tokens) + ,docstring + (argot:parse ,name tokens))))))) |