lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, Dec 30, 2021 at 12:51 PM Flyer31 Test <> wrote:
> You use the '$' start char here to  'define you private command world".
Oh sorry, that '$' just means the ole bash prompt I seem to spend my
life in. In fact, el will work on Windows as well with a wrapper, and
then that prompt would be '>'!

So this is something I have just copied from my terminal:

~/dev/el$ cat el.lua | el  mmatch L ^'^function IDEN' ^if+ ^^end :
update it 2 len : push it end sort it 2 gt : slice it 1 5

What it does is this: each 'el' is a command invocation which first
reads a little Lua file called .el. So it can remember state, if you
say 'el set tau=2*pi' then this definition of 'tau' will appear in

el just translates its command line into plain Lua (set ELDBG=1 to see
the results) and then runs that.

the mmatch function is interesting and might be useful elsewhere - it
runs a little state machine with Lua patterns, so first we pick up the
function name, for each 'if' we add the match, and the 'end' we reset
state and start looking for 'function' again.So we get the number of
if-statements in each global function. (I suspect that I am merely
recovering a form of regular expressions, but on a line-by-line basis)

steve d.