aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-08-08 07:23:02 -0700
committercolin <colin@cicadas.surf>2023-08-08 07:23:02 -0700
commit911e5868ab281a1fdb82b84b63aa35411933ceae (patch)
treeab6495673f1efdeaa597b78cfd74b946b2402c02
parent0f42ae0e6d61e344e10604bc9b82f033fcdb91c9 (diff)
changed :doc to :note in rule specs
-rw-r--r--README.org14
-rw-r--r--argot.lisp19
-rw-r--r--examples/calc.lisp4
-rw-r--r--grammars.lisp2
4 files changed, 23 insertions, 16 deletions
diff --git a/README.org b/README.org
index e345bcf..9a8b710 100644
--- a/README.org
+++ b/README.org
@@ -21,10 +21,12 @@ In ~/examples/calc.lisp~ you see the following ~deflanguage~:
(<expr>
:match (:or <subexpr> <value> <unop> <binop>))
(<subexpr>
- :match (:{} calc))
+ :match (:{} calc)
+ :doc "A subexpression, like (1 + 2 / cos(1.5))")
(<value>
:match (:item)
- :if numberp)
+ :if numberp
+ :doc "A Number")
(<binop>
:match (:seq
(:@ lhs <expr>)
@@ -75,7 +77,11 @@ Function:
<VALUE> ::= ::TOKEN::
<BINOP> ::= <EXPR> ('+' | '-' | '/' | '*' | '^' | '%') <EXPR>⁤+
<UNOP> ::= ('SIN' | 'COS' | 'TAN' | '-') <EXPR>
-
+------------------------------------------
+ADDITIONAL NOTES:
+<SUBEXPR> A subexpression, like (1 + 2 / cos(1.5))
+<VALUE> A Number
+------------------------------------------
KEY:
::TOKEN:: Any ole token
::EOF:: Explicitly match the end of the input
@@ -213,3 +219,5 @@ clause, it can be either a function designator or an arbitrary expression.
When ~<rule3>~ succeeds, it returns a list of two values.
+*** Additional Docstrings
+
diff --git a/argot.lisp b/argot.lisp
index b52052e..e95fe3f 100644
--- a/argot.lisp
+++ b/argot.lisp
@@ -68,10 +68,10 @@ and it returns VAR in that case."
(let ((pattern (getf options :match))
(check (getf options :if))
(action (getf options :then))
- (doc (getf options :doc)))
+ (note (getf options :note)))
(unless (and (nonterminal? lhs) (pattern? pattern))
(error 'invalid-rule-def :rule ruledef))
- (list lhs pattern (collect-vars pattern) check action doc))))
+ (list lhs pattern (collect-vars pattern) check action note))))
(defun function-form-p (s)
@@ -104,13 +104,13 @@ and it returns VAR in that case."
(let ,bindings
(declare (ignorable ,lhs ,@vars))
,action))))))
- (rule-includer (name lhs pattern &optional check action bindings vars doc)
+ (rule-includer (name lhs pattern &optional check action bindings vars note)
`(include-rule
(get ',name 'argot::grammar-property)
(make-rule
:lhs ',lhs
:pattern ',pattern
- :doc ,doc
+ :note ,note
,@(expand-functional-argument :check lhs bindings check vars)
,@(expand-functional-argument :action lhs bindings action vars)))))
(let* ((parsed-rules
@@ -118,9 +118,9 @@ and it returns VAR in that case."
:collect (handler-case (parse-rule-def ruledef)
(invalid-rule-def (e) (invoke-debugger e)))))
(rule-adder-forms
- (loop :for (lhs pattern vars check action doc) :in parsed-rules
+ (loop :for (lhs pattern vars check action note) :in parsed-rules
:for bindings := (collect-let-bindings lhs vars)
- :collect (rule-includer name lhs pattern check action bindings vars doc)))
+ :collect (rule-includer name lhs pattern check action bindings vars note)))
(docstring
(with-output-to-string (*standard-output*)
(princ documentation)
@@ -133,13 +133,12 @@ and it returns VAR in that case."
(terpri)
(princ "ADDITIONAL NOTES:")
(terpri)
- (loop :for (lhs _p _v _c _a doc) :in parsed-rules
+ (loop :for (lhs _p _v _c _a note) :in parsed-rules
;:for lhs-name := (symbol-name lhs)
- :when doc
+ :when note
:do (format *standard-output* "~15a ~a~%"
lhs
- ;(subseq lhs-name 1 (1- (length lhs-name)))
- doc))
+ note))
(princ "------------------------------------------")
(terpri)
(princ "KEY: ") (terpri)
diff --git a/examples/calc.lisp b/examples/calc.lisp
index 0a25a6b..fc9e854 100644
--- a/examples/calc.lisp
+++ b/examples/calc.lisp
@@ -17,11 +17,11 @@
:match (:or <subexpr> <value> <unop> <binop>))
(<subexpr>
:match (:{} calc)
- :doc "A subexpression, like (1 + 2 / cos(1.5))")
+ :note "A subexpression, like (1 + 2 / cos(1.5))")
(<value>
:match (:item)
:if numberp
- :doc "A Number")
+ :note "A Number")
(<binop>
:match (:seq
(:@ lhs <expr>)
diff --git a/grammars.lisp b/grammars.lisp
index c9a1c55..54505b7 100644
--- a/grammars.lisp
+++ b/grammars.lisp
@@ -4,7 +4,7 @@
;;; GRAMMAR & RULES
-(defstruct rule lhs pattern action check doc)
+(defstruct rule lhs pattern action check note)
(defclass grammar ()
((rules