Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regex higher IR library
#3
(Jun-05-2022, 05:46 AM)Gribouillis Wrote:
(Jun-04-2022, 11:37 PM)DreamingInsanity Wrote: but it's not in a very useful format for doing other stuff with.
Why is this not useful enough and what do you want to do with it? It looks like a regular syntax tree (by the way on my system it is sre_parse.parse())
I called it not useful because there's no documentation on the syntax tree, which makes it hard to understand sometimes, and I wouldn't say its designed so that it's easy for to use outside of the re module. Having an object or classes over lists of tuples is just easier for working with the syntax tree, for example:
class SubPattern:
	pat: Any

class Repetition:
	pat: Any
	greedy: bool

class WordBoundary:
	pass

# (\w+) becomes:
SubPattern(Repetition(WordBoundary, True))
# instead of
[(SUBPATTERN, (1, 0, 0, [(MAX_REPEAT, (1, MAXREPEAT, [(IN, [(CATEGORY, CATEGORY_WORD)])]))]))]
Gribouillis Wrote: what do you want to do with it
I want to be able to generate a "priority" for a regex. For example (abc) has a higher priority than ([a-c]+) as the former is more explicit and will only match abc versus 1 or more of the a, b, or c characters as the latter would match. And (a|bc) would have a priority higher than ([a-c]+) but lower than (abc), as its shortest match is a which is shorter than abc as the longer regex is prioritised more.
Reply


Messages In This Thread
Regex higher IR library - by DreamingInsanity - Jun-04-2022, 11:37 PM
RE: Regex higher IR library - by Gribouillis - Jun-05-2022, 05:46 AM
RE: Regex higher IR library - by DreamingInsanity - Jun-05-2022, 10:06 AM
RE: Regex higher IR library - by Gribouillis - Jun-05-2022, 03:12 PM
RE: Regex higher IR library - by DreamingInsanity - Jun-05-2022, 04:07 PM
RE: Regex higher IR library - by Gribouillis - Jun-05-2022, 06:21 PM
RE: Regex higher IR library - by DreamingInsanity - Jun-06-2022, 02:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner Higher Lower Game wallytan 2 1,670 Sep-29-2022, 05:14 PM
Last Post: deanhystad
  finding the next higher representable floating point value Skaperen 0 1,983 Sep-13-2019, 11:16 PM
Last Post: Skaperen
  the next higher character Skaperen 13 5,038 Jun-07-2019, 01:44 PM
Last Post: heiner55
  How do I loop through a list and delete numerical elements that are 1 lower/higher? neko 4 4,354 Sep-05-2017, 02:25 PM
Last Post: ichabod801
  PyInstaller, how to create library folder instead of library.zip file ? harun2525 2 4,886 May-06-2017, 11:29 AM
Last Post: harun2525

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020