all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Rustom Mody <rustompmody@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: APL mode
Date: Sat, 12 Oct 2013 15:08:37 -0400	[thread overview]
Message-ID: <jwvzjqepb8v.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAJ+TeodhST9VE=YZE+mpzCtT4NGzAbFvfLxYWQ1cpV7OKa-2KQ@mail.gmail.com> (Rustom Mody's message of "Sat, 12 Oct 2013 21:39:24 +0530")

>>> What does sexp mean for non-lisp languages like C etc?
>>> (Needed for functions like forward-sexp)
>> It means "a subtree in the abstract syntax tree".
> In principle, that's fine. However in practice there are things like
> a. comments which do not exist in the AST

comments should normally be skipped by forward-sexp.

> b. preprocessor commands that appear and disappear before ASTs are on the
> scene

Indeed, there are cases where the source code does not correspond to
a tree (and not even a DAG either).  In that cases, the expected
behavior of forward-sexp is undefined (i.e. total freedom).

> c. (most important) emacs doesnt really do a full-scale context free
> grammar analysis does it?

Not sure what you man by "Emacs" here: Emacs just runs the code provided
by the major mode author, so it's the major mode's author's
responsibility to make sure forward-sexp works as it should.

> So I guess I am asking: Emacs uses regular exps to fudge a semblance of
> context free structure. How does it do this?

There's `forward-sexp-function' which lets you write your parser by
hand.

Else, there's a very simplistic builtin parser, which doesn't know about
infix operators and only know how to skip "normal" comments, how to
recognize "normal" strings, and how to skip parentheses (and related
pairs, with restrictions such as: the opening and closing markers are
single chars).  The "grammar" for this parser is given in the form of
what we call a "syntax-table".

In between, there's SMIE which does precedence parsing.  It's a very
weak grammar, but since we want to parse backward (for backward-sexp),
it's a good option since, contrary to LL/LR and friends it's fully
symmetric.  We use it for various different modes: Coq, SML, OCaml,
Prolog, sh, Ruby, Modula-2, Octave, css.


        Stefan "who doesn't know much about APL's syntax"



  reply	other threads:[~2013-10-12 19:08 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-12  4:48 APL mode Rustom Mody
2013-10-12  7:25 ` Thien-Thi Nguyen
2013-10-12 14:26 ` Stefan Monnier
2013-10-12 16:09   ` Rustom Mody
2013-10-12 19:08     ` Stefan Monnier [this message]
2013-10-13  6:45     ` Stephen J. Turnbull
2013-10-13  6:59       ` Rustom Mody
2013-10-13 11:10         ` Stephen J. Turnbull
2013-10-13 14:04           ` Rustom Mody
2013-10-13 15:35             ` Stephen J. Turnbull
2013-10-13 16:11             ` Ivan Andrus
2013-10-13 12:42 ` Rüdiger Sonderfeld
2013-10-13 14:47   ` Rustom Mody
2013-10-13 15:24     ` Rüdiger Sonderfeld
2013-10-14  5:00       ` Rustom Mody
2013-10-14  6:45         ` Rustom Mody
2013-10-14 13:34           ` Stefan Monnier
2013-10-14  8:21         ` Xue Fuqiao
2013-10-14 11:08           ` Rustom Mody
2013-10-17 18:54             ` David De La Harpe Golden
2013-10-17 19:26               ` Stefan Monnier
2013-10-20 13:57                 ` Rustom Mody
2013-10-21 10:46                   ` Xue Fuqiao
2013-10-21 13:03                   ` Stefan Monnier
2013-10-25 19:09                     ` Rustom Mody
2013-10-26  1:40                       ` Stefan Monnier
2013-10-26  4:38                         ` Rustom Mody
2013-10-26 10:35                           ` Juergen Sauermann
2013-10-26 11:42                             ` Rustom Mody
2013-10-26 15:40                             ` David De La Harpe Golden
2013-10-26 16:48                               ` Rustom Mody
2013-10-26 17:41                                 ` Rustom Mody
2013-10-26 17:48                                 ` David De La Harpe Golden
2013-10-27  5:08                           ` Stefan Monnier
2013-10-27 22:41                             ` Xue Fuqiao
2013-10-28  4:09                             ` Stephen J. Turnbull
2013-10-28 12:21                               ` Rustom Mody
2013-10-28 12:40                                 ` Juergen Sauermann
     [not found]                                   ` <CAJ+Teofv_2bHhdAvxsVRY8EYLQO6ERZ_zbAWh0FLQnUMndcfSg@mail.gmail.com>
     [not found]                                     ` <526E669E.60501@t-online.de>
     [not found]                                       ` <CAJ+TeofjYsy4eLDr=aM3Vo36=76zipbn7HmXcm59YNwkgLoaSg@mail.gmail.com>
     [not found]                                         ` <526E7EC3.3050305@t-online.de>
     [not found]                                           ` <526E967F.3010903@harpegolden.net>
     [not found]                                             ` <526E9DCE.8080504@t-online.de>
2013-10-28 17:42                                               ` Rustom Mody
2013-10-28 19:45                                                 ` David De La Harpe Golden
2013-10-18  7:06               ` Rustom Mody
2013-10-14 10:40         ` Rüdiger Sonderfeld
2013-10-14 17:03 ` David De La Harpe Golden
2013-10-14 19:48   ` Stefan Monnier
2013-10-15  3:15   ` Rustom Mody
  -- strict thread matches above, loose matches on Subject: below --
2013-10-12  5:01 Rustom Mody

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvzjqepb8v.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=rustompmody@gmail.com \
    /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.
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.