Changeset trunk,10
- Timestamp:
- 06/18/2007 04:17:50 PM (19 years ago)
- revision id:
- svn-v3-trunk0:2948df59-2b31-0410-8e06-c40c0b09d5b6:trunk:10
- File:
-
- 1 edited
-
trunk/parse3.lisp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/parse3.lisp
r9 r10 5 5 6 6 (defmacro if-matcher-parser (input parser (next match) 7 &body (&optional (then t) else))7 &body (&optional (then t) else)) 8 8 (declare (symbol parser next match)) 9 9 (with-gensyms (ok) … … 12 12 13 13 (defmacro if-matches-char (input char (next match) 14 &body (&optional (then t) else))14 &body (&optional (then t) else)) 15 15 (declare (symbol next match) 16 16 (character char)) … … 34 34 35 35 (defmacro if-matches-regex (input regex (next match) 36 &body (&optional (then t) else))36 &body (&optional (then t) else)) 37 37 (declare (string regex) 38 38 (symbol next match)) … … 48 48 49 49 (defmacro if-matches-choice (input alts (next match) 50 &body (&optional (then t) else))50 &body (&optional (then t) else)) 51 51 (declare (symbol next match) 52 52 (list alts)) … … 66 66 `(if-matches ,input ,head (,head-next ,head-match) 67 67 (if-matches-sequence ,head-next ,tail (,next ,tail-match) 68 (let ((,match ( append ,head-match ,tail-match)))68 (let ((,match (cons ,head-match (list ,tail-match)))) 69 69 ,then) 70 70 ,else) 71 71 ,else)) 72 (with-gensyms (head-match) 73 `(if-matches ,input ,head (,next ,head-match) 74 (let ((,match ,head-match)) 75 ,then) 76 ,else))))) 72 `(if-matches ,input ,head (,next ,match) ,then ,else)))) 77 73 78 74 (defmacro if-matches-eqcount (input count rule (next match) 79 &body (&optional (then t) else))75 &body (&optional (then t) else)) 80 76 "WARNING: ELSE code executes in an anonymous block!" 81 77 (declare ((or null (integer 0)) count) … … 88 84 (if-matches ,next ,rule (,next2 ,match2) 89 85 (setf ,next ,next2 90 ,match ( nconc ,match (list ,match2)))86 ,match (cons ,match2 ,match)) 91 87 (return-from ,r ,else))) 88 (setf ,match (nreverse ,match)) 92 89 ,then)))) 93 90 94 91 (defmacro if-matches-maxcount (input count rule (next match) 95 &body (&optional (then t) else))92 &body (&optional (then t) else)) 96 93 (declare ((or null (integer 0)) count) 97 94 (symbol next match) … … 105 102 (progn 106 103 (psetf ,next ,next2 107 ,match ( nconc ,match (list ,match2))104 ,match (cons ,match2 ,match) 108 105 ,i (1+ ,i)) 109 106 t))))) 107 (setf ,match (nreverse ,match)) 110 108 ,then))) 111 109 112 110 (defmacro if-matches-count (input mincount maxcount rule (next match) 113 &body (&optional (then t) else)) 111 &body (&optional (then t) else)) 112 (when (and maxcount mincount) (setf maxcount (- maxcount mincount))) 114 113 (with-gensyms (next2 match2) 115 114 `(if-matches-eqcount ,input ,mincount ,rule (,next2 ,match2)
Note: See TracChangeset
for help on using the changeset viewer.
