indentation idea



Hello,

I came across Paolo's plan on custom indenter on this bug:
https://bugzilla.gnome.org/show_bug.cgi?id=736727#c19
and found it interesting.

If I understand well, the essence of indenter implementation is to find
a paren-like expression, by looking at the text around the cursor.
Apparently the current implementations in Builder and
gedit-code-assistance are doing that with hand-crafted string matching
rules.

On the other hand, Emacs nowadays ships with a generic indentation
engine called SMIE, which utilizes operator precedence grammar, so it
can reliably find a matching expressions like: "if" ... "then" ... "fi"
http://www.gnu.org/software/emacs/manual/html_node/elisp/SMIE.html#SMIE

I'm thinking of using the same algorithm to make indenter
implementations easier.  What do people think?

As a POC, I ported the basic part of SMIE (written in Elisp) to C:
https://github.com/ueno/c-smie

Though it is still a draft, it contains a sh-like grammar and an
interactive demo, which you can play with.

Comments appreciated.

Regards,
-- 
Daiki Ueno


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