diff options
author | colin <colin@cicadas.surf> | 2023-08-08 07:03:48 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-08-08 07:03:48 -0700 |
commit | 2cdb3b48802d904fe5ed85235fcd5bb3d58be15a (patch) | |
tree | f572bc736f155430feb136bb9e19044a4cefa7bd | |
parent | 0ed3ee0fe326c5259effa1456ac58e0d26e38c4b (diff) |
Removed dependency on trivia
-rw-r--r-- | argot.asd | 8 | ||||
-rw-r--r-- | argot.lisp | 35 | ||||
-rw-r--r-- | package.lisp | 1 |
3 files changed, 16 insertions, 28 deletions
@@ -1,12 +1,12 @@ ;;;; argot.asd (asdf:defsystem #:argot - :description "Describe argot here" - :author "Your Name <your.name@example.com>" - :license "Specify license here" + :description "Grammar-driven Macro Definition" + :author "Colin <colin@cicadas.surf>" + :license "GPLv3" :version "0.0.1" :serial t - :depends-on (#:trivia #:alexandria) + :depends-on (#:alexandria) :components ((:file "package") (:file "grammars") (:file "docgen") @@ -57,29 +57,18 @@ and it returns VAR in that case." (collect-vars (cdr pat)))))) (defun parse-rule-def (ruledef) - (handler-case - (ematch ruledef - ((guard (list lhs :match pattern) - (and (nonterminal? lhs) (pattern? pattern))) - (list lhs pattern (collect-vars pattern) nil nil)) - - ((guard (list lhs :match pattern :if check) - (and (nonterminal? lhs) (pattern? pattern))) - (list lhs pattern (collect-vars pattern) check nil)) - - ((guard (list lhs :match pattern :then action) - (and (nonterminal? lhs) (pattern? pattern))) - (list lhs pattern (collect-vars pattern) nil action)) - - ((guard (list lhs :match pattern :then action :if check) - (and (nonterminal? lhs) (pattern? pattern))) - (list lhs pattern (collect-vars pattern) check action)) - - ((guard (list lhs :match pattern :if check :then action) - (and (nonterminal? lhs) (pattern? pattern))) - (list lhs pattern (collect-vars pattern) check action))) - (trivia::match-error () - (error 'invalid-rule-def :rule ruledef)))) + (unless (consp ruledef) + (error 'invalid-rule-def :rule ruledef)) + + (destructuring-bind (lhs . options) ruledef + (let ((pattern (getf options :match)) + (check (getf options :if)) + (action (getf options :then)) + (doc (getf options :doc))) + (unless (and (nonterminal? lhs) (pattern? pattern)) + (error 'invalid-rule-def :rule ruledef)) + (list lhs pattern (collect-vars pattern) check action doc)))) + (defun function-form-p (s) (or (functionp s) diff --git a/package.lisp b/package.lisp index 0bbaec6..1e3ac22 100644 --- a/package.lisp +++ b/package.lisp @@ -2,6 +2,5 @@ (defpackage #:argot (:use #:cl) - (:import-from #:trivia #:match #:ematch #:guard) (:import-from #:alexandria #:if-let) (:export #:defgrammar #:deflanguage #:parse)) |