Browse files

* Grammar transformation mechanism is implemented from scratch using


* Add a new section to README about how to introduce new
  transformation directives.

* Bump version.
  • Loading branch information...
Volkan YAZICI committed Aug 1, 2007
1 parent b0c5286 commit e760934c08d5e104a71f1f954a5ffca7501348e4
Showing with 160 additions and 95 deletions.
  1. +50 −4 README
  2. +1 −2 meta-sexp.asd
  3. +108 −85 meta-sexp.lisp
  4. +1 −4 packages.lisp
@@ -8,10 +8,10 @@ commonly used streams, for efficiently stepping backward and forward
through the input. It is tested on SBCL but should be portable to
other implementations as well.
-meta-sexp is implemented using modular transformation processors.
+meta-sexp is implemented using sevaral transformation methods.
Therefore, besides builtin grammar transformators coming with
-meta-sexp, you can easily add your own transformation keywords to
-meta-sexp too. (See DEFINE-TRANSFORMATION macro in meta-sexp.lisp.)
+meta-sexp by default, you are allowed to add your own transformation
+methods too.
Inspired by src/parser.lisp of core-stream project at
@@ -215,4 +215,50 @@ iii. Treat as a custom form. (Will get evaluated as is)
When you're in the third situation, to be able to get your META
s-expressions compiled again, use META keyword. (See the second
-example in the Quick Introduction.)
+example in the Quick Introduction.)
+ ,---------------------------------.
+ `---------------------------------'
+Every transformation process issued by meta-sexp is controlled by
+ (defgeneric transform-grammar (ctx in-meta directive &optional args)
+ (:documentation "META grammar transformation methods."))
+To introduce a new transformation directive, just create a new
+TRANSFORM-GRAMMAR method with related lambda list specializers. For
+instance, consider how :AND and :NOT directive transformations are
+ (defmethod transform-grammar
+ (ctx (in-meta (eql t)) (directive (eql :and)) &optional args)
+ `(and ,@(mapcar #'(lambda (form) (transform-grammar ctx t form))
+ args)))
+ (defmethod transform-grammar
+ (ctx (in-meta (eql t)) (directive (eql :not)) &optional args)
+ (transform-grammar
+ ctx t :checkpoint
+ `((not ,(transform-grammar ctx t (car args))))))
+Also pay attention how meta-sexp handles unrecognized transformation
+ (defmethod transform-grammar (ctx in-meta directive &optional args)
+ "The most unspecific transformation method."
+ (declare (ignore args))
+ (cond
+ ((and in-meta (consp directive) (keywordp (car directive)))
+ (transform-grammar ctx t (car directive) (cdr directive)))
+ ((and (not in-meta) (consp directive) (eql 'meta (car directive)))
+ (transform-grammar ctx t :and (cdr directive)))
+ ((consp directive)
+ (mapcar #'(lambda (form) (transform-grammar ctx nil form))
+ directive))
+ (t directive)))
+With similar patterns, you can introduce new transformation directives
+to meta-sexp.
@@ -33,14 +33,13 @@
(in-package :meta-sexp-asd)
-(defconstant +meta-sexp-version+ "0.1.3")
+(defconstant +meta-sexp-version+ "0.1.4")
(export '+meta-sexp-version+)
(asdf:defsystem :meta-sexp
:serial t
:version +meta-sexp-version+
:components ((:file "packages")
- (:file "specials")
(:file "util")
(:file "meta-sexp")
(:file "atoms")))
Oops, something went wrong.

0 comments on commit e760934

Please sign in to comment.