From 2cdb3b48802d904fe5ed85235fcd5bb3d58be15a Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 8 Aug 2023 07:03:48 -0700 Subject: Removed dependency on trivia --- argot.asd | 8 ++++---- argot.lisp | 35 ++++++++++++----------------------- package.lisp | 1 - 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/argot.asd b/argot.asd index ff57f4d..e3141b8 100644 --- a/argot.asd +++ b/argot.asd @@ -1,12 +1,12 @@ ;;;; argot.asd (asdf:defsystem #:argot - :description "Describe argot here" - :author "Your Name " - :license "Specify license here" + :description "Grammar-driven Macro Definition" + :author "Colin " + :license "GPLv3" :version "0.0.1" :serial t - :depends-on (#:trivia #:alexandria) + :depends-on (#:alexandria) :components ((:file "package") (:file "grammars") (:file "docgen") diff --git a/argot.lisp b/argot.lisp index 1eb7fc5..f79e2ed 100644 --- a/argot.lisp +++ b/argot.lisp @@ -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)) -- cgit v1.2.3