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

From: Oliver Andrich <[email-masked]>
Date: Tue, 28 Feb 95 17:06:37 MET

Helloo everybody!

What is the reason for the following?

"]" == "\]"

All tests said, that these two strings are equal. But how could I
parse strings where "]" is command character or so but "\]" is legal
syntax for using "]" as a normal character?

BTW, i don't want to convert a strings to list, I want to use such
nice features as char or aref when I am using vector.

Bye, Oliver

---

From: [email-masked] (Peter Dudey Drake)
Date: Thu, 9 Mar 95 09:29:52 PST

Just off the top of my head...

Have you tried "\\]" and/or "\\\]"?

+-     PETER DUDEY DRAKE      279-D SE Lilly Ave.,  Corvallis, OR  97333     -+
|       MS student in Artificial Intelligence, Oregon State University        |
|   "I was bored.  You know how it is when two science guys start talking."   |
|						-Tom Paris		      |
+-  [email-masked]        (finger [email-masked])  -+

---

From: Oliver Andrich <[email-masked]>
Date: Fri, 10 Mar 95 12:08:45 MET

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 \]. 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.

Bye Oliver

---

From: Matthias Lindner <[email-masked]>
Date: Fri, 10 Mar 95 13:45:42 +0100

Oliver Andrich writes:
 > 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

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: [email-masked]
WWW: http://aida.intellektik.informatik.th-darmstadt.de/~matthias/
------------------------------------------------------------------------------

---

From: Oliver Andrich <[email-masked]>
Date: Mon, 13 Mar 95 11:43:51 MET

Hello Peter!

> What else did you expect? 

Well, I expected, if I read from a string-char-stream with
read-char-sequence that I get a sequence of the characters from the
input stream. And I expected the characters are the same as in the
input-file. 

> If you want to skip the '\]'s, you have to 
Nope! If I make a string-char-input-stream with the string above or a
file containing the string, I dont't get what you said, but you get 
"[foo [ bar ] baz ]".

> you can do much better in (C)LISP! :)

But slower.

Bye Oliver