[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SMIE & transpose-sexps

From: krisajenkins
Subject: SMIE & transpose-sexps
Date: Thu, 27 Feb 2014 03:54:06 -0800 (PST)
User-agent: G2/1.0


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
        '((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


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?


* 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 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]