unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>,
	 emacs-devel <emacs-devel@gnu.org>
Subject: Re: Writing syntax-propertize-function for strings in code in strings, etc
Date: Fri, 26 Oct 2012 23:18:10 +0400	[thread overview]
Message-ID: <508AE1F2.4000408@yandex.ru> (raw)
In-Reply-To: <jwvlietxls1.fsf-monnier+emacs@gnu.org>

On 26.10.2012 20:19, Stefan Monnier wrote:
>>> I think the better approach is to extend syntax.c with such a notion of
>>> "syntax within strings".  This could hopefully be used for:
>>> - Strings within strings (e.g. Postscript nested strings).
>>> - Comments within strings (I think some regexps allow comments).
>>> - Code within strings (as here and in shell scripts).
>>> I'm not sure what that would look like concretely.  Maybe a new string
>>> quote syntax which specifies a syntax-table to use within the string?
>> In the current case, the syntactic meanings of characters are the same as
>> outside the string, except a certain character should end the "inner" region
>> and return the state after it to "inside string" (*).
>
> Right, that's the "code within string" case, where you just need one
> char to mean "pop last state".

Or that last character's text would just be assigned a class from the 
syntax-propertize-function, no different syntax table required.
Not sure how useful would the first option be.

>> Maybe just two new classes, similar to open and close parenthesis (to
>> support nesting)?
>
> Yes, one "push <inner-syntax-table>" and one "pop".

So, I don't see the usefulness of the <inner-syntax-table> value in the 
simple case of embedding code in the same language.

Unless we're doing something like the "multiple-modes" use case, which 
we discussed in another thread. This looks like a more general solution.

> Of course, this is fine for parse-partial-sexp, but it's a different
> matter for backward-sexp, where the "pop" would also need to know the
> <inner-syntax-table>.

Maybe in the latter case the scanning function, when encountering the 
"pop" syntax property, would just skip ahead until it finds the 
corresponding "push"?
Unless we want to support intersecting subregions, like ([{])}.

>> parse-partial-sexp will probably need to keep some sort of stack for
>> string-related data, so that when we're after the end of an "inner" region,
>> we could find out what is the outer string's type and where it started.
>> And when inside the inner region, the position of its start.
>> Use the 9th state element and bump the total number to 10?
>
> The total number is already 10.  And yes, I think we can use the 9th
> element.  Currently, the 9th element is a stack of open-paren positions.
> So, I think we can reuse it (presumably we'd want parens and nested
> strings to be "mutually properly nested").

--Dmitry



  parent reply	other threads:[~2012-10-26 19:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-08  3:23 Writing syntax-propertize-function for strings in code in strings, etc Dmitry Gutov
2012-09-08 19:31 ` Stefan Monnier
2012-09-09  0:13   ` Dmitry Gutov
     [not found]   ` <504FE870.7070002@yandex.ru>
     [not found]     ` <jwvlietxls1.fsf-monnier+emacs@gnu.org>
2012-10-26 19:18       ` Dmitry Gutov [this message]
2012-10-26 20:41         ` Stefan Monnier
2012-10-26 21:52           ` Dmitry Gutov
2012-10-28 15:46             ` Stefan Monnier
2012-11-02  4:54               ` Dmitry Gutov
2012-11-15  1:40                 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=508AE1F2.4000408@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).