all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Leake <stephen_leake@member.fsf.org>
To: emacs-devel@gnu.org
Subject: Re: access to parser stack in SMIE
Date: Mon, 08 Oct 2012 18:58:49 -0400	[thread overview]
Message-ID: <85vcek1sgm.fsf@member.fsf.org> (raw)
In-Reply-To: <857gr1da6d.fsf@member.fsf.org> (Stephen Leake's message of "Sun,  07 Oct 2012 21:28:26 -0400")

Stephen Leake <stephen_leake@member.fsf.org> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>> 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.

It turns out you were right. Scanning backwards is better, because there
is one additional test you can apply; as you cross each Ada statement or
declaration, you can check which it was (statement or declaration), and
that tells you whether you have begin-open or begin-body.

So you typically only have to go back one statement, not all the way to
the top. I can construct a worse case scenario that requires scanning to
the top, but it's pretty pathological code.

That still involves encountering unrefined "begin", but you just recurse
on that, no problem.

I've implemented that, and removed my local copy of smie.el. The code is
quite straight-forward, not much more hairy than the code it replaces.
And this technique should work for the other places I thought I needed
full parse-forward. I hereby withdraw my request for smie--levels.

Thanks for pushing me on this :).

I've kept the cache; it's simple, and it should speed things up quite a
bit. I'll try to measure how much when I'm all done.

I'll still play with semantic; there are front-end tools like code
completion and function call template that rely on it. But it's less
urgent.

-- 
-- Stephe



  reply	other threads:[~2012-10-08 22:58 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
2012-10-08 22:58             ` Stephen Leake [this message]
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=85vcek1sgm.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.