This repo holds a simple python script that converts a custom syntax into a proper regex statements. This was made out of frustration for the horrible experience of creating large regex statements and getting lost in the sauce
First feature that everyone will enjoy, the lovely comment:
// comment
Who wouldn't want their completely white text document containing a regex statement to have even more white text?
This is currently the only other feature here, and is where nearly all of the code goes to. Macros are similar to those you will find in C-based languages. They replace macro definitions in the statement with a direct string.replace() call
# macro_name <
// ...
>
The direct-inject macro does pretty much what you would expect. It takes the contents inside, and directly replaces itself with those contents
# macro_name {
//...
}
This one does pretty much the same thing as its counterpart, but injects the contents inside a regex group (...). This was only done for code cleanliness since you will often create macros for groups anyway
Macros will prioritize replacing larger-length macro names first. The following example below will help you understand why this is:
# macro <
:(
>
# big_macro <
:)
>
big_macro
The expected result of the above statement would be the happy expression :). If the smaller macro definition were to be prioritized, the result would be the unhappy expression big_:(. We don't want big sad, so we prioritize larger definitions