all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* SMIE & transpose-sexps
@ 2014-02-27 11:54 krisajenkins
  2014-02-28  2:30 ` Stefan Monnier
       [not found] ` <mailman.16218.1393554659.10748.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: krisajenkins @ 2014-02-27 11:54 UTC (permalink / raw)
  To: help-gnu-emacs

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."


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-10 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-27 11:54 SMIE & transpose-sexps krisajenkins
2014-02-28  2:30 ` 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

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.