gel a Gema/Lua integration

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

gel a Gema/Lua integration

Remo Dentato
I just released the first public versione of Gel, the integration of lua with gema a really powerful macro processor:
 
Gema (written by David N Gray) can greatly ease the task of parsing files that have nested expressions or that require context sensitive matching. Gel adds the capability of calling lua chunks upon matching.
 
If you think it might be useful for you, have a look at http://gel-tool.sourceforge.net . Any comment is appreciated.
 
Regards,
                                            Remo
 
Reply | Threaded
Open this post in threaded view
|

Re: Gel a Gema/Lua integration

Ashish Ranjan-2
Hi Remo,
  Its a very nice work. I appreciate by heart. This
can be a handy tool. 
  In some aspects, gel brings very much raw text
processing power more than perl etc., while keeping
language very simple.
bye :-)
Ashish
[hidden email]
> 
> I just released the first public versione of Gel,
> the integration of lua with gema a really powerful
> macro processor:


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Reply | Threaded
Open this post in threaded view
|

[ANN] Gel 0.2

Remo Dentato
An update version of gel is available at http://gel-tool.sourceforge.net.
This version has a "gema-like" interface and no longer a Lua interpreter
interface.

I've also added a little bit of documentation.

To make you, hopefully, a little bit more interested here is an example.
Let's imagine we have to solve the following problem:

<< Collect identifiers from a file and sourround them with "<id>" and
"</id>" tags. If it's not the first time you encounter that identifers, add
the attribute "first" to the id tag with the line where you first
encountered it as value. At the end, write a sorted index of identifiers
with the line where they first appear.>>

Here is a possible solution in gel:

----8<---- cut -----8<---- cut -----8<---- cut -----8<----
![
id_ln={}; n_id={}; table.setn(n_id,0)

function check_id(id,ln)
  local t=""
  if id_ln[id] then
    t=" first=\""..id_ln[id].."\""
  else
    id_ln[id]=ln
    table.insert(n_id,id)
  end
  return "<id"..t..">"..id.."</id>"
end

function sort_id()
  table.sort(n_id)
  gel.write("\n")
  for n,id in pairs(n_id) do
    gel.write(id.." "..id_ln[id].."\n")
  end
end
!]

<I>=@lua{return check_id("$0",@line)}
\Z=@lua{sort_id()}

----8<---- cut -----8<---- cut -----8<---- cut -----8<----

Short enough, isn't it?

Enjoy,
                                                Remo



Reply | Threaded
Open this post in threaded view
|

Re: Gel a Gema/Lua integration

Remo Dentato
In reply to this post by Ashish Ranjan-2
Hi Ashish, you said:

>   Its a very nice work. I appreciate by heart. This can be a handy tool.

Thanks! I've just posted the announcement of a new release, I hope you will
find it useful.
Any comment is appreciated.

Regards,
                                                            Remo