
Show HN: Sed to C translator written in sed - lhoursquentin
https://github.com/lhoursquentin/sed-bin
======
ketanmaheshwari
Nice! In the why part you speculatively mention better speed. Do you have any
concrete benchmark results?

If fast, the tool would be very useful for my work where I run an
anonimization sed script with hundreds of transformations on millions of lines
that takes hours to run.

But even if it is not fast, this is a fun project.

~~~
segfaultbuserr
Not the author, but I see that

> _no pattern /hold space overflow checks, currently both limited to 8192
> bytes as per the POSIX spec requirement. Going over that limit will most
> likely cause a segfault._

> _The C code is very rough around the edges (by that I mean dirty and unsafe,
> for instance allocating everything on the stack without checking any
> overflow), I 'm still working on it, but contributions (issues/comments/pull
> requests) are also welcomed :)_

Thus, so far it's just for fun, not suitable for profit yet.

~~~
lhoursquentin
Yep that's exactly right :) !

To clarify my statement POSIX requires _at least_ 8192 bytes for the pattern
and hold space, and I chose to allow at most 8192 bytes here, which indeed
means that this will prevent working on really long lines or storing entire
files in the hold space for instance.

------
girst
wow--impressive!

the core is here ([https://github.com/lhoursquentin/sed-
bin/blob/master/par.sed](https://github.com/lhoursquentin/sed-
bin/blob/master/par.sed)), and it's 600 lines of beautifully commented sed

------
tgv
So it can translate itself?

> Translate the translator (par.sed) with itself:

Yes! Congrats!

------
rkeene2
And for the other direction (C->sed):
[https://github.com/shinh/elvm](https://github.com/shinh/elvm)

------
easytiger
Genuinely very cool. Nice work.

------
sheerun
Now one for Awk and Python please :)

~~~
mftrhu
There's already an awk-to-C compiler [1], even if it seems to be unmaintained.
Python has a couple of them, more or less constrained, including Nuitka [2].

[1]
[http://awka.sourceforge.net/index.html](http://awka.sourceforge.net/index.html)

[2] [https://github.com/Nuitka/Nuitka](https://github.com/Nuitka/Nuitka)

~~~
sheerun
I mean awk-to-Python transcompiler, it would be useful for datascience. I
wonder if it's possible to use awka to create such thing.

