all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Possibility for a stream editor (sed) inside emacs ?
@ 2011-05-24 23:08 Alin Soare
  2011-05-25 13:11 ` Ted Zlatanov
  0 siblings, 1 reply; 2+ messages in thread
From: Alin Soare @ 2011-05-24 23:08 UTC (permalink / raw)
  To: Emacs Dev


[-- 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 --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-25 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-24 23:08 Possibility for a stream editor (sed) inside emacs ? Alin Soare
2011-05-25 13:11 ` Ted Zlatanov

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.