Changeset trunk,27
- Timestamp:
- 06/25/2007 09:36:52 PM (19 years ago)
- revision id:
- svn-v3-trunk0:2948df59-2b31-0410-8e06-c40c0b09d5b6:trunk:29
- Location:
- trunk
- Files:
-
- 2 edited
-
csv.lisp (modified) (3 diffs)
-
parsing.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/csv.lisp
r26 r27 23 23 ("." illegal)) 24 24 25 (defun lex-all-csv (input &optional tokens) 26 (format t "~&Lexing '~A...'~%" (subseq input 0 40)) 27 (multiple-value-bind (class image left) (lex-csv input) 28 (cond 29 ((and class (eq class 'illegal)) 30 (princ "oops") 31 (error "Illegal input")) 32 (class 33 (lex-all-csv left (cons (list class image) tokens))) 34 (t 35 (nreverse tokens))))) 25 (defun lex-all-csv (input) 26 (labels ((lex-all (start tokens) 27 (multiple-value-bind (class image next-offset) 28 (lex-csv input start) 29 (cond 30 ((and class (eq class 'illegal)) 31 (error "Illegal input")) 32 (class 33 (lex-all next-offset (cons (cons class image) tokens))) 34 (t 35 (nreverse tokens)))))) 36 (lex-all 0 nil))) 36 37 37 38 (defmacro defmatcher (class) … … 39 40 `(defun ,fn-sym (token-list) 40 41 (when token-list 41 (destructuring-bind (class image) (first token-list)42 (destructuring-bind (class . image) (first token-list) 42 43 (when (eq class ',class) 43 44 (values t (rest token-list) (list image)))))))) … … 52 53 (file (+ row)) 53 54 (row (t-value (* row-rest) (= t-newline)) 54 (lambda (row) 55 (mapcar #'car (cons (first row) (mapcar #'second (second row)))))) 55 (lambda (row) (cons (caar row) (mapcar #'second (second row))))) 56 56 (row-rest ((= t-comma) t-value) car)) 57 57 -
trunk/parsing.lisp
r21 r27 32 32 `(defun ,name (input) 33 33 (if-matches input ,rule (next match) 34 (values t next ( list',name ,(if filter `(,filter match) 'match))))))34 (values t next (cons ',name ,(if filter `(,filter match) 'match)))))) 35 35 36 36 (defmacro defgrammar (() &body definitions)
Note: See TracChangeset
for help on using the changeset viewer.
