Add Regex Engine to FEX for config option loading#5120
Add Regex Engine to FEX for config option loading#5120badumbatish wants to merge 10 commits intoFEX-Emu:mainfrom
Conversation
|
I'm unsure on a full regex engine, I think a very naive glob impl might be enough. albeit this is very neat |
Sonicadvance1
left a comment
There was a problem hiding this comment.
Other than the concern about the licensing of the regex engine used, I'm fine with this type of change.
There was a problem hiding this comment.
I'm unsure on a full regex engine, I think a very naive glob impl might be enough. albeit this is very neat
I'd like to echo this - adding a full-blown regex engine without documentation and bare-bones unit tests is overkill for the concrete feature this PR intends to add. (Though I do appreciate that there are tests :) )
Could you focus the implementation on pure wildcards (* instead of .*) instead, without unions and the other features that we don't need for config matching? That should allow for throwing away most of the complexity here, notably the use of NFAs.
This doesn't necessarily imply a rewrite (up to you). Deleting the relevant code and taking a quick pass over what's left would yield an equally simpler result.
|
I've gone ahead and removed some features like unions, escapables, question, plus. Please let me know if this is sufficient for the PR |
neobrain
left a comment
There was a problem hiding this comment.
Thanks, this is much easier to read :)
Adding a few more comments, no big changes though!
Source/Common/Config.cpp
Outdated
| // Matches the first and then get out | ||
| // Needs PR review on this |
There was a problem hiding this comment.
I mainly would want to know if the current approach of applying the config is good or not
|
Oh, you'll also want to run clang-format-19 on any newly added code. (I think most of us have our IDEs set up to auto-format on save.) |
gotacha i'll install it |
|
Apologies for the delay i was on vacation. I've addressed the comments |
No worries, though you arrived just in time for my vacation and sadly no one else was around to take over the review. Not exactly sure what's going on with the CI build failures - could you rebase the PR onto latest main to see if it still happens then? |
|
The CI build failures come from pulling in headers from a FEXCore library but the test isn't linking to that library. |
Hi there, i'm opening the PR to add a small regex engine to the Fex codebase. The motivation is to help dynamic modify some config option based on the name of the config file. Please see the following screenshot for more context.
.
The regex engine is an NFA based one, implemented from the dragon book 2nd ed.
Implementation is in
FEXCore/Source/Utils/Regex.cpp.Test case is
unittests/APITests/Regex.cpp.I took the liberty to refactor and reuse a bit of the code in parsing the json. The traversing of a json list of pair of strings is now a helper function called ListApplier that accepts a
json_t.The default behavior is that the config loader goes through each regex and see if it matches the config name, if it does, it applies the config option specified and then stops checking anymore regex (this can change based on the need and reviews of the PR).
I'm not sure where should i add the test case for the new config loader. I tested locally via
/home/ubuntu/.fex-emu/Config.jsonand it works, would love some suggestions