Jun-04-2022, 11:37 PM
Before I delve into making my own module, I was wondering if there already exists a regex higher IR (intermediary representation) of regex tokens for python
I can import the actual regex parser from
For python, I find searching for regex related projects online pretty difficult as most results end up being something along the lines of how to use re or regex in python, but I would be surprised if something like the other projects shown doesn't exist in python. It wouldn't need to support any advanced regex features like lookaheads, but just have a better way of representing regex tokens.
Does anyone know of a module like this?
Thanks,
Dream
I can import the actual regex parser from
re
like:from re._parse import parse parse("reg|ex")and it gives an output like
Output:[(BRANCH, (None, [[(LITERAL, 114), (LITERAL, 101), (LITERAL, 103)], [(LITERAL, 101), (LITERAL, 120)]]))]
but it's not in a very useful format for doing other stuff with. Similar libraries exist in Rust regex_syntax::hir or JS's regexp-tree.For python, I find searching for regex related projects online pretty difficult as most results end up being something along the lines of how to use re or regex in python, but I would be surprised if something like the other projects shown doesn't exist in python. It wouldn't need to support any advanced regex features like lookaheads, but just have a better way of representing regex tokens.
Does anyone know of a module like this?
Thanks,
Dream