From: krisajenkins@gmail.com
To: help-gnu-emacs@gnu.org
Subject: SMIE & transpose-sexps
Date: Thu, 27 Feb 2014 03:54:06 -0800 (PST) [thread overview]
Message-ID: <e513f33d-453f-420c-8202-68470b659481@googlegroups.com> (raw)
Hi,
I'm trying to wrap my head around SMIE, and I think I'm stumbling on something I thought would be pretty basic. I'm hoping someone can help...
I've written some simple rules like this:
(defconst my-grammar
(smie-prec2->grammar
(smie-precs->prec2
'((assoc "=")
(assoc "AND")))))
And I'm trying it out with a simple string like this:
a = b AND c = d
My (perhaps naive) assumption was that, with that enabled I could call:
a |= b AND c = d
M-x transpose-sexps =>
b |= a AND c = d
And:
a = b AND| c = d
M-x transpose-sexps =>
c = d AND| a = b
And that this would be both jolly useful in itself, and proof that I'd set up the parsing rules correctly. But it doesn't work, and I have no idea why. I do know that if I switch either token to a comma, it works for that token.
Does anyone know where I'm going wrong? Is what I'm trying to do even possible*? And if it's not possible, is there any other way to verify the parse tree, before I start trying to indent it?
Thanks,
Kris
* This line from the docs makes me believe it is: "For example, if the provided grammar is precise enough, transpose-sexps can correctly transpose the two arguments of a + operator, taking into account the precedence rules of the language."
next reply other threads:[~2014-02-27 11:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-27 11:54 krisajenkins [this message]
2014-02-28 2:30 ` SMIE & transpose-sexps Stefan Monnier
[not found] ` <mailman.16218.1393554659.10748.help-gnu-emacs@gnu.org>
2014-02-28 12:11 ` Kris Jenkins
2014-03-10 15:12 ` 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=e513f33d-453f-420c-8202-68470b659481@googlegroups.com \
--to=krisajenkins@gmail.com \
--cc=help-gnu-emacs@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.
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).