From: Alin Soare <as1789@gmail.com>
To: Emacs Dev <emacs-devel@gnu.org>
Subject: Possibility for a stream editor (sed) inside emacs ?
Date: Wed, 25 May 2011 02:08:05 +0300 [thread overview]
Message-ID: <BANLkTinrYm6qk9PVA=g=Jtfntp-As+EJDw@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 2154 bytes --]
Last 2 days I played, and I wrote a toy sed (stream-editor). I did use and
learn sed, and to convince myself if I understood it, I wanted to write an
own sed.
My purpose was to write the machine that makes the computations, and not to
write a complete sed. Its parser that generates tokens for example does not
jump over the spaces. It's just a toy sed.
The machine generates the internal structure that can be used by a virtual
machine to render every sed command.
I did not write neither the virtual machine (I wrote just a little sketch
for a vm, and a sketch of lazy-evaluator of the special forms of conditional
and non conditional branch "s label" and "t label"), and neither the action
functions, that should be called by this machine via apply. I wrote only
the kernel of sed. For me it became clear, and I do not want any more to
work on.
The virtual machine that evaluates the data structure that I generated can
be written to use Emacs internal buffers or elisp strings, instead of files,
as the GNU/sed does.
The data structure I generated can also be used quite directly to generate
the precise indentation of sed scripts, without defining the *action
functions for every command, using the same logic I used when I wrote the
indentation of lisp code ( ignored! ):
http://permalink.gmane.org/gmane.emacs.devel/100252.
I attach the backus-naur form I wrote last days. In order to understand the
code, you have to look in the same time to bn-form. I wrote a major mode
called "backus naur mode" to browse the backus-naur forms. The most
difficult part of the implementation was to generate the graph with the
mutual recursive function Command and Command_block. This is why I used
artist-mode to draw a picture of the data structures, starting from atomic
expressions of sed, upto the creation of the branches of Blocks.
I attach the implementation of sed, and the grammar of sed in bn-form, and a
file bn-mode.el , in order for those of you who are interested to be able to
browse the grammar. I posted the bn-mode long time ago, but the post was
ignored.
Do you consider, an internal stream editor would be good for emacs?
Alin
[-- Attachment #1.2: Type: text/html, Size: 2362 bytes --]
[-- Attachment #2: sed.tar.bz2 --]
[-- Type: application/x-bzip2, Size: 9640 bytes --]
next reply other threads:[~2011-05-24 23:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-24 23:08 Alin Soare [this message]
2011-05-25 13:11 ` Possibility for a stream editor (sed) inside emacs ? Ted Zlatanov
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTinrYm6qk9PVA=g=Jtfntp-As+EJDw@mail.gmail.com' \
--to=as1789@gmail.com \
--cc=emacs-devel@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).