Changeset trunk,6 for trunk/parse2.lisp
- Timestamp:
- 06/08/2007 06:37:29 PM (19 years ago)
- revision id:
- svn-v3-trunk0:2948df59-2b31-0410-8e06-c40c0b09d5b6:trunk:6
- File:
-
- 1 edited
-
trunk/parse2.lisp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/parse2.lisp
r5 r6 51 51 52 52 (defmacro with-regex-parser ((name regex) &body body) 53 (error "Not implemented.")) 53 (declare ((symbol name) 54 (string regex))) 55 (follow "with-regex-parser~%") 56 (let ((regex2 `(:sequence (:flags) :start-anchor 57 (:register (:regex ,regex))))) 58 (with-gensyms (input start end) 59 `(flet ((,name (,input) 60 ,(format nil "Regex parser for ~S." regex) 61 (declare (string ,input)) 62 (multiple-value-bind (,start ,end) (scan (quote ,regex2) ,input) 63 (when ,start 64 (values 65 t 66 (substring ,input :start ,end) 67 (list (substring ,input :end ,end))))))))))) 68 69 (defmacro with-user-parser ((name parser) &body body) 70 (declare (symbol name parser)) 71 (follow "with-user-parser~%") 72 (with-gensyms (input) 73 `(flet ((,name (,input) 74 ,(format nil "User parser for ~S." parser) 75 (,parser ,input))) 76 (declare (inline ,name)) 77 ,@body))) 54 78 55 79 (defmacro with-sequence-parser% ((name seq) &body body) … … 181 205 (character `(with-character-parser (,name ,rule) ,@body)) 182 206 (string `(with-string-parser (,name ,rule) ,@body)) 207 (symbol `(with-user-parser (,name ,rule) ,@body)) 183 208 (list 184 209 (destructuring-bind (head . tail) rule
Note: See TracChangeset
for help on using the changeset viewer.
