Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom rewrite rule sets as input #26

Merged
merged 27 commits into from
Jan 25, 2024
Merged

Support custom rewrite rule sets as input #26

merged 27 commits into from
Jan 25, 2024

Conversation

fizruk
Copy link
Collaborator

@fizruk fizruk commented Jan 11, 2024

Based on #9. Closes #11.

  • Generic (naïve) mechanism for normalization (Language.EO.Phi.Rules.Common)
  • User-defined rules (with YAML configuration) (Language.EO.Phi.Rules.Yaml)
  • Basic CLI:
    • --rules-yaml FILE
    • --chain (not implemented yet)
  • Sample rules file (based off Yegor's rules) (yegor.yaml)
  • A few unit tests

Known issues/limitations:

  • Not all conditions/patterns are supported:
    • presence/absence of an attribute
    • (in)equality of attributes
    • reference to global object bindings
    • global counter
    • attribute (re)naming utilities
  • isNF condition does not adequately represent intended restrictions (need to consider context somehow)
  • Cannot support minimal calculus (locator substitution is not implemented/available)
  • Missing documentation
  • Not enough tests

PR-Codex overview

Focus of this PR:

This PR focuses on introducing new features and improvements to the EO Phi normalizer.

Detailed summary:

  • Added support for MetaObject and MetaBindings in the Object data type.
  • Updated the Syntax.cf grammar file to include the MetaId token.
  • Updated the Syntax.Par.y parser file to handle the MetaId token.
  • Modified the Setup.hs file to use the --haskell flag when invoking bnfc.
  • Updated the VS Code settings file to set the default formatter for Haskell files.
  • Added new test cases and test files for user-defined rules.
  • Updated the Language.EO.Phi module to import qualified modules.
  • Made various improvements and bug fixes to the codebase.

The following files were skipped due to too many changes: eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y, eo-phi-normalizer/eo-phi-normalizer.cabal, eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt, eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs, eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs, eo-phi-normalizer/app/Main.hs, eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

| (y, ys) <- select xs
]

matchFindBinding :: Rules.Binding -> [Phi.Binding] -> [([Phi.Binding], Subst)]
Copy link
Member

@deemp deemp Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't be non-deterministic here as it can badly affect the performance (IDK if laziness saves us).

So, maybe apply listToMaybe instead of returning a list?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sensible suggestion if we expect at most one match. However, this is not currently the case if Rule.Binding contains a metavariable binding (i.e. we should match any metavariable). To make this efficient we should then somehow stop and let other part of the matching figure out what metavariable we are talking about, which can be done in some places by rearranging order of matching (for example, for ObjectDispatch). However, this is not possible in general without constraint-based matching.

@fizruk fizruk marked this pull request as ready for review January 23, 2024 09:12
@fizruk fizruk merged commit cd54497 into master Jan 25, 2024
4 checks passed
@fizruk fizruk deleted the custom-rules branch January 25, 2024 18:55
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.

Implement a user-defined rules language
3 participants