SLRE: Super Light Regular Expression library

Started by airr, May 04, 2024, 01:44:07 PM

Previous topic - Next topic

airr


MrBcx

#21
Quote from: MrBcx on May 17, 2024, 08:19:46 AM
That is a stunningly useful piece of code!

However ... it shuts down a moment after it starts up when compiled with MSVC2022.  I haven't dug deeper yet.

On the plus side, it compiles and runs fine using Pelles, Lcc-Win32, Mingw (NuWen), and Clang.

The attached file is a modified version of dl2str.inc

It has a bit more error checking but more importantly, compiles and runs correctly using
Pelles, Lcc-Win32, Mingw (Nuwen), Clang, MSVC (msvcrt and ucrt)


Thanks

MrBcx

Quote from: airr on May 17, 2024, 12:35:59 AM

Going back to the Cesanta version for a sec:

AIR.

That is a stunningly useful piece of code!

However ... it shuts down a moment after it starts up when compiled with MSVC2022.  I haven't dug deeper yet.

On the plus side, it compiles and runs fine using Pelles, Lcc-Win32, Mingw (NuWen), and Clang.


airr

Going back to the Cesanta version for a sec:


#include "slre.c"
$Include "dl2str.inc"

$Typedef struct slre_cap slre_cap

Dim As Integer a, b
Dim buffer$[BCXSTRSIZE*5]
Dim bcxList$*65535
Dim bcxName$[20]

Dim As slre_cap cap[BCXSTRSIZE]

DownloadToStr(&bcxList$, "https://bcxbasiccoders.com/archives/YahooGroups/Bcx_Files_New")

If bcxList$ > "" Then
    b = Split(buffer$, bcxList$, Lf$)
    For Integer i = 0 To b-1
        If slre_match("archives.+(Bcx8\d+\.zip)>.+", buffer$[i], Len(buffer$[i]), cap, BCXSTRSIZE, 1) > 0 Then
            bcxName$[a] = Left$(cap[0].ptr$, cap[0].len)
            a++
        End If
    Next
End If

Qsort bcxName$, a, Descending

Print "Latest BCX Filename: ", bcxName$[0]

Pause



AIR.

airr

Another option:  This is an MIT-Licensed version, according to the header file.

https://github.com/oprypin/slre

airr

I understand.  Generally when I look for stuff to use with BCX I try to find those that have the least restrictive license too.

Well, at least we have the option of using the original version with it's Beer-Ware license.  Would be a fun project to add functionality to it, no?

AIR.

morgan

#16
airr no, i wanted to give it a try
a long time ago when i found it.
buf after i discovered the license issue
i gave up.


mr bcx, gpl is not a software to deal with, for me.

the minimum for me is lgpl
but ofcurse i would preffer mit/bsd and so.

airr

#15
I couldn't resist, here's a rudimentary example using the ORIGINAL SLRE version from SourceForge:


#include "slre.c"

Dim test$
test$ = "DIM HelpMenu AS HMENU"

$Typedef struct slre slre
$Typedef struct cap  cap

Dim As slre sl
Dim As cap captures[BCXSTRSIZE]

If Not slre_compile(&sl, "^DIM\s+?(.+)\s+?\S+\s+?(\S+)") Then
    Print "Error compiling RE: ", sl.err_str$
    End = 1
End If

If Not slre_match(&sl, test$, Len(test$), captures) Then
    Print "No Matches Found"
    End = 1
End If

Print "Variable Name: ", Left$(captures[1].ptr$, captures[1].len)
Print "Variable Type: ", Left$(captures[2].ptr$, captures[2].len)

Pause



AIR.

Edit:  Forgot to mention that I had to edit the source to address warnings about incompatible assignments.

MrBcx

Quote from: morgan on May 13, 2024, 12:35:02 PM
anyway as i said (from memory)
and now checked it
this library started with permissive license
but now it is under a company
with other license
https://github.com/cesanta/slre/

The developer of SLRE is also the Founder/Director of Cesanta.

The Cesanta/slre is dual-licensed ... meaning, you can either buy a commercial license from
Cesanta or, if you commercialize your software, GPL2 requires you to open source your app.

If you don't sell your app then both licenses are pointless.

airr

Hi, Morgan.

Is the issue for you primarily the license?

I did a quick diff between the two (at work so limited time) and it seems that the 'newer' version has undergone extensive refactoring.

Have you tried either one with code you're writing?

AIR.

morgan

i already said this above
this is the old code
it has modified since then

Robert

#11
Quote from: morgan on May 13, 2024, 12:35:02 PM
anyway as i said (from memory)
and now checked it
this library started with permissive license
but now it is under a company
with other license
https://github.com/cesanta/slre/

Hi Morgan:

MrBCX used SLRE in his Fast File Search.

FFS.zip

https://bcxbasiccoders.com/mrbcx_samples/mrbcx.htm

the source code of Sergey Lyubka is still available on the website

https://slre.sourceforge.net/

which has this license

Quote

* Copyright (c) 2004-2005 Sergey Lyubka <valenok@gmail.com>
* All rights reserved
*
* "THE BEER-WARE LICENSE" (Revision 42):
* Sergey Lyubka wrote this file.  As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return.
*

morgan

anyway as i said (from memory)
and now checked it
this library started with permissive license
but now it is under a company
with other license
https://github.com/cesanta/slre/

morgan

i think it ' s very old example
that i found on bcx archive.
yesterday i made a search there
i didn't find mrbcx files.
what am i missing ?

Robert