emacs-devel
[Top][All Lists]
Advanced

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

Re: help with smie


From: Stephen Leake
Subject: Re: help with smie
Date: Fri, 22 Feb 2013 13:11:25 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (windows-nt)

Josh <address@hidden> writes:

> On Thu, Feb 21, 2013 at 11:40 AM, Yagnesh Raghava Yakkala
> <address@hidden> wrote:
>> So I decided to first try SMIE work for another small major mode called
>> namelist-modeĀ². Namelist files are sort of configuration files Fortran
>> programs (you may already know that).
>> [...]
>> I wrote smie rules in the mode, tried to see how it works. No surprise they
>> didn't work.
>
> I tried a similar exercise recently, with similar results.  I read in
> (info "(elisp) SMIE setup")
> that SMIE's "main entry point is `smie-setup' which is a function
> typically called while setting
> up a major mode."  Would it make sense to add an example of a simple
> SMIE-based major
> mode to (info "(elisp) Example Major Modes") ?

There are some fairly simple language modes using SMIE in the Emacs 24
sources; modula2, octave, prolog, sh-script. Do a 'grep' in
emacs-24.2.92/lisp/progmodes.

I've implemented Ada using SMIE; see
http://stephe-leake.org/emacs/ada-mode/emacs-ada-mode.html

I found it most helpful to have a set of Ada source code files that I
could run the indentation engine on, using edebug to step thru the code
when things didn't work.

I didn't see any source code files at https://github.com/yyr/namelist-mode

I glanced at the code in
https://github.com/yyr/namelist-mode/blob/master/namelist-mode.el

namlist-smie-tokens isn't used anywhere. It appears to be trying to
create aliases for the actual tokens. That will probably be more
confusing than it is worth.

You need an expression list, and a group list in your grammar; your
current grammar only allows one group per file, and one expression per
group.

Try:

(exp-list 
 (exp)
 (exp-list exp))

Once you get used to it, the SMIE way of doing an indentation engine is
quite nice, for a small language.

-- 
-- Stephe



reply via email to

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