Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Outline

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

Syntax

Comments

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?

Macros

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

Direct-Inject Macro

# 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

Wrapped Macro

# 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

Behavior to look out for

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

About

Compiles custom file syntax (.rgx) to usable regular expressions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages