[climacs-devel] Case missing from class regexp's print-object method
Derek Peschel
dpeschel at eskimo.com
Sat Aug 27 21:47:20 UTC 2005
A regexp object may temporarily have a KIND slot of nil, but the print-object
method can't handle that case. In normal use this doesn't matter, but when
tracing the parsing functions, the debugger tries to call print-object
on fresly-created regexp objects. So I've taken a stab at a patch, copied
below.
It may be a good idea to create a similar case in the REGEXP-AUTOMATON method
but I don't know what the action of the case should be.
It may also be a good idea to have an output syntax that can't be mistaken
for any legal input. The real Perl engine, and many clones, first try to
read a quantifier when they see a left brace. If the read fails they reread
the "quantifier" as a string of literal characters. If Automaton ever copied
that dubious feature, then my current syntax would become legal input.
So is it best to just choose a new "magic" character or string now?
Or perhaps objects should be intiialized so they print out as "()" or "#"
(without the quotes).
-- Derek
*** regexp.lisp Sat Aug 27 13:50:55 2005
--- regexp.lisp.new Sat Aug 27 14:39:25 2005
***************
*** 54,59 ****
--- 54,65 ----
;;; non-negative decimal integers and include both end points, and if
;;; n and m have the same number of digits, then the conforming
;;; strings must have that length (i.e. prefixed by 0's).
+ ;;;
+ ;;; The printout "{nilkind}" denotes a regexp object whose KIND slot
+ ;;; has not been initialized by the parsing routines. Debugging or
+ ;;; tracing can cause such objects to be printed. The language has
+ ;;; no syntax for uninitialized regexp objects and the "{nilkind}"
+ ;;; notation was designed to cause a syntax error when read.
(in-package :automaton)
***************
*** 162,167 ****
--- 168,175 ----
(defmethod print-object ((r regexp) s)
(ecase (kind r)
+ ((nil)
+ (princ "{nilkind}" s))
(:union
(princ "(" s)
(print-object (exp1 r) s)
More information about the climacs-devel
mailing list