[cl-ppcre-devel] Porting to Genera, feature request

Patrick O'Donnell pao at ascent.com
Wed Sep 15 17:27:23 UTC 2004


Hi, Edi,

I just downloaded cl-ppcre to see if it would help with some parsing
I'm working on.  I thought I'd drop you a line just to alert you to
the issues I ran into.  I don't think they're worth a lot of
attention, but just so you know they're there.

I'm doing development on Genera, and there were several issues with
compiling cl-ppcre, mostly due to Genera not quite being ANSI
compliant.  I finally got it to compile and ran the test.  Some (21)
of the tests failed.  Most of the failures, I've noted are based on
assumptions about character codes that do not hold for Genera
(e.g. test 432 -- line termination (char-code #\Return) -> #o215, not
#o12.)  The others I haven't thoroughly investigated.  I believe that
I'll be able to use the limited features I need, and if I run into
trouble, I'll let you know.

The feature that I'd like to see relates to your s-expression parse
tree capability.  I'd like to abstract sub-parse-trees.  A small
change to the end of convert-aux,

            (otherwise
              (let ((translation (get parse-tree 'parse-tree-synonym)))
		(if translation
		    (convert-aux translation)
		    (signal-ppcre-syntax-error "Unknown token ~A in parse-tree"
					       parse-tree))))

and a quick macro,

(defmacro DEFINE-PARSE-TREE-SYNONYM (name parse-tree)
  `(setf (get ',name 'ppcre::parse-tree-synonym) ',parse-tree))

and I can do something like:

(define-parse-tree-synonym A (:CHAR-CLASS (:RANGE #\a #\z) (:RANGE #\A #\Z)))
(define-parse-tree-synonym X (:CHAR-CLASS (:RANGE #\a #\z) (:RANGE #\A #\Z) :DIGIT-CLASS))
(define-parse-tree-synonym N :DIGIT-CLASS)
(define-parse-tree-synonym SMA-DATE (:SEQUENCE n n a a a))
(define-parse-tree-synonym AIRLINE-DESIGNATOR (:SEQUENCE x x (:GREEDY-REPETITION 0 1 a)))
(define-parse-tree-synonym FLIGHT-NUMBER (:GREEDY-REPETITION 3 4 n))
(define-parse-tree-synonym OPERATIONAL-SUFFIX (:GREEDY-REPETITION 0 1 a))

(defparameter *flight-scanner*
	(ppcre:create-scanner '(:sequence airline-designator
					  flight-number
					  operational-suffix
					  "/"
					  sma-date)))

Much more perspicuous, especially in more complex parse trees where
the abstracted elements are repeated.

Just a thought.

		- Patrick O'Donnell
		  pao at ascent.com




More information about the Cl-ppcre-devel mailing list