[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is "]" == "\]"?



Oliver Andrich writes:
 > Hello Peter!
 > 
 > > Have you tried "\\]" and/or "\\\]"?
 > >
 > That is not the point. My input data looks like that "[..... some text
 > \[ some more text \] even more text]", and I want to locate with
 > search the [ and ], but my clisp or any other lisp I tried stops at
 > the \]. 

What else did you expect? If you want to skip the '\]'s, you have to 
implement this (in LISP or in any other language). Your problem is 
absolutely not related to LISPs *reading* syntax. 
If your input file contains a line like this:
[ foo \[ bar \] baz ] 

(read-line your-file-stream) will produce this:
"[foo \\[ bar \\] baz ]"

So there should be no problem for you!

To find the closing ] try something like this:

(defun FIND-CLOSING-] (string)
  (do ((pos (position #\] string :test #'char=)
	    (position #\] string :test #'char= :start (1+ pos))))
      ((or (null pos)
	   (zerop pos)
	   (not (char= #\\ (char string (1- pos))))
	   (and (> pos 1)
		(char= #\\ (char string (- pos 2)))))
       pos)))

 > Ok, I can preparse the input data with perl or so, but then I
 > can do the whole transforming from SGF-Format to my LISP-data
 > structure with perl.

And don't forget: EVERYTHING you can do in perl or any other language
you can do much better in (C)LISP! :)

have fun

--Matthias

------------------------------------------------------------------------------
Matthias Lindner
FG Intellektik, FB Informatik
Technische Hochschule Darmstadt
Alexanderstr.10, D-64283 Darmstadt
TEL: +49 6151 166651
FAX: +49 6151 165326
NET: matthias@intellektik.informatik.th-darmstadt.de
WWW: http://aida.intellektik.informatik.th-darmstadt.de/~matthias/
------------------------------------------------------------------------------