Skip to content

Improvements to RequisiteParser (Packrat Parsing)#164

Open
Yogeb-tech wants to merge 10 commits intodevelopfrom
packrat-requisite-parser
Open

Improvements to RequisiteParser (Packrat Parsing)#164
Yogeb-tech wants to merge 10 commits intodevelopfrom
packrat-requisite-parser

Conversation

@Yogeb-tech
Copy link
Copy Markdown
Contributor

@Yogeb-tech Yogeb-tech commented Apr 17, 2026

These are the main improvements I've made:

  • All parser rules are now defined in a single central registry, rather than being scattered across the codebase.
  • Introduced a packrat parser structure that others can build on for more complex expression handling.
  • Decoupled regex patterns from matcher logic, making rules easier to read and modify.

That said, I haven’t utilized the packrat parser as well as I should have. Ideally, each smaller parser could still keep its own regex patterns for now (change them later), but the next step would be adding a top-level packrat parser would handle AND/OR requirements, parentheses, and address any edge cases.

Currently:

  • ParseRequirement() still uses manual strings.Split and recursion for AND/OR, and groupParens() to track parentheses
    • Therefore, adding a top-level packrat parser with NewAndParser, NewKleeneParser would be a good solution.
    • This top level parser would be able to parse through all the child parsers, replacing this recursive string parsing and greatly simplifying ParseRequirement
  • groupParens() should be removed once packrat handles recursion properly
  • Replacing parseGroup() usage in choice matcher with the packrat parser could also be beneficial

I would like to step away for this issue for a bit, if someone else could handle some of these changes, that would be great :)
I'm open to any suggestions or concerns about my proposed future changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant