-
Notifications
You must be signed in to change notification settings - Fork 3
/
parsing-macro-2.lisp
26 lines (23 loc) · 1.06 KB
/
parsing-macro-2.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(in-package #:cl-yaclyaml)
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro define-alias-rule (alias rule)
`(define-yaclyaml-rule ,alias ()
(progn ,(maybe-wrap-in-descent rule)
nil))))
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro define-context-forcing-rule (context-name forsee-name &optional (expression forsee-name))
`(define-yaclyaml-rule ,(symbolicate context-name "-" forsee-name) ()
(let ((context ,(make-keyword context-name)))
,(maybe-wrap-in-descent expression)))))
;; KLUDGE: better to learn how to define alias names for ESRAP contexts
(eval-when (:compile-toplevel :load-toplevel :execute)
(defmacro define-yy-rule (symbol args &body body)
`(define-yaclyaml-rule ,symbol ,args ,@body))
(defmacro yy-parse (expression text &key (start nil start-p)
(end nil end-p)
(junk-allowed nil junk-allowed-p))
`(yaclyaml-parse ,expression ,text
,@(if start-p `(:start ,start))
,@(if end-p `(:end ,end))
,@(if junk-allowed-p
`(:junk-allowed ,junk-allowed)))))