From: Stephen Leake <stephen_leake@member.fsf.org>
To: emacs-devel@gnu.org
Subject: Re: access to parser stack in SMIE
Date: Sun, 07 Oct 2012 21:28:26 -0400 [thread overview]
Message-ID: <857gr1da6d.fsf@member.fsf.org> (raw)
In-Reply-To: <jwvfw5p23v3.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 07 Oct 2012 21:00:11 -0400")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Yes. Which is why the cache is critical. And improving the cache by
>> storing the stack at each keyword would be even better.
>
> That can lead to a very large cache, which can then become slow to
> manage. In syntax-ppss we keep the intermediate state of the parse
> every ~20KB. So that if we have to re-parse at most ~20KB's worth
> of text.
That makes sense.
>> But it's messier and less general than the forward parse
>> mechanism, and the other tokens that need forward parse would need their
>> own variations.
>
> I get the impression that a
>
> (let ((begin-flavor nil))
> (while (let ((s (smie-backward-sexp 'halfsexp)))
> (null (setq begin-flavor (ada--begin-flavor s))))))
>
> wouldn't be that hard to write and that ada--begin-flavor would look
> similar to your current function that looks at the stack items.
> But of course, here, details matter, so we can't know without actually
> trying it out.
Yes. I should look at this again; it might be better than what I have now.
>> (setq stack-token (nth 0 (rassoc (pop stack) ada-indent-grammar)))
>
> Hmm... indeed, by relying on the identity of the cons cells in the
> stack, you can recover the actual token, even if 2 tokens have the same
> left&right precedence.
> It should be the case in all real-life situations, but nothing
> guarantees that it's the case.
> Hmm...
Ah, I never even considered that it might not be unique. That makes this
technique less satisfactory; to be safe, we'd have to add the actual
token to the stack.
I did wonder why the stack didn't have the actual token; I guess you
didn't need it for anything yet.
--
-- Stephe
next prev parent reply other threads:[~2012-10-08 1:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-06 4:21 access to parser stack in SMIE Stephen Leake
2012-10-06 12:37 ` Stefan Monnier
2012-10-06 18:55 ` Stephen Leake
2012-10-07 19:04 ` Stefan Monnier
2012-10-07 23:18 ` Stephen Leake
2012-10-08 1:00 ` Stefan Monnier
2012-10-08 1:28 ` Stephen Leake [this message]
2012-10-08 22:58 ` Stephen Leake
2012-10-09 2:26 ` Stefan Monnier
2012-10-09 3:29 ` Stephen Leake
2012-10-09 4:20 ` Stefan Monnier
2012-10-09 11:23 ` Stephen Leake
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=857gr1da6d.fsf@member.fsf.org \
--to=stephen_leake@member.fsf.org \
--cc=emacs-devel@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.