[Top][All Lists]

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

Re: Raw string literals in Emacs lisp.

From: David Kastrup
Subject: Re: Raw string literals in Emacs lisp.
Date: Sun, 03 Aug 2014 09:29:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

"Stephen J. Turnbull" <address@hidden> writes:

> David Kastrup writes:
>  > r#"?\" is a complete string.  How do you parse it backwards?
> By catching the parse error when parsing it as a (normal) string, then
> reparsing it as a raw string (ie, running backwards over the
> characters until you hit the second ?"), and check for a leading #r
> (two tokens of lookahead).
> Thanks for the example, David, XEmacs is buggy here (or maybe
> terminating a rawstring with \ will be declared illegal ;-).

Uh, I wasn't planning to trip up XEmacs.  At any rate, things can get
more complex, like with

(format "%s%c\n""r#"?\") => "r#\"

which is valid Elisp right now and would remain so, but which would look
like containing a valid string r#"?\" after the syntax change when
scanning backwards.  It's not like syntax highlighting etc don't revert
to heuristics (like with "(" in first column), but it's still obvious
that this choice is not conflict-free.  And I don't see how one could
reasonably get around that without also changing the ending delimiter.

David Kastrup

reply via email to

[Prev in Thread] Current Thread [Next in Thread]