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

423 custom rules #432

Merged
merged 13 commits into from
Jul 19, 2024
Merged

423 custom rules #432

merged 13 commits into from
Jul 19, 2024

Conversation

fizruk
Copy link
Collaborator

@fizruk fizruk commented Jul 12, 2024

This PR aims to close #423. However, the implementation diverges with the initial proposal. Here is what is in this PR:

  • Test ruleset streams.yaml with the example rule equipped with with a passing test, matching Custom rules. Iteration 2 #423 (comment)
  • Allow rules to go inside abstract objects (and add explicit apply_in_abstract_subformations option to maintain correctness for yegor.yaml rules)
  • Support tail patterns (restricted one-hole contexts)
    • Matching against objects inside dispatch
    • Matching against objects inside application (left only)
  • Properly generate fresh names
  • Allow explicit forall to keep track of all metavariables for extra safety (force in the future, see Force explicit declaration of pattern variables #441)
  • Distinguish types of metavariables for extra safety
  • Document extensions for custom rules with examples (left for future work, see Document updates to the custom rules #439)

Here are the differences with the initial proposal in #423:

  1. Metavariable identifiers start with ! and we do not (yet) distinguish their types (attribute/object/binding/etc.).
  2. Instead of t1 * t2 we use one-hole context patterns !C1 [1| obj |1]. The notation is subject to change (in particular, we may allow obj * !C1, for example). Importantly, the one-hole context pattern allows to match against objects in application arguments.
  3. forall is implicit: all metavariables used in the pattern are automatically put under the forall.
  4. exists is replaced with fresh (and can only yield fresh attributes).
  5. Only one pattern and result are supported, multiple pattern-result pairs will be supported later (see Support multiple patterns and results in custom rules #440).

PR-Codex overview

This PR updates object and meta ID handling in the EO Phi normalizer.

Detailed summary

  • Replaced MetaId with specific ID types like LabelMetaId
  • Added MetaTailContext and updated related functions
  • Updated test file with new ID types and rules
  • Updated grammar rules for ID tokens

The following files were skipped due to too many changes: eo-phi-normalizer/src/Language/EO/Phi/Rules/Common.hs, eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.x, eo-phi-normalizer/test/eo/phi/rules/yegor.yaml, eo-phi-normalizer/src/Language/EO/Phi/Syntax/Print.hs, eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.y, eo-phi-normalizer/src/Language/EO/Phi/Syntax/Doc.txt, eo-phi-normalizer/src/Language/EO/Phi/Rules/Yaml.hs

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

@fizruk fizruk requested a review from deemp July 12, 2024 09:41
@fizruk fizruk marked this pull request as ready for review July 19, 2024 11:15
@fizruk fizruk merged commit f3b4f1c into master Jul 19, 2024
8 checks passed
@fizruk fizruk deleted the 423-custom-rules branch July 19, 2024 14:12
@0crat
Copy link

0crat commented Jul 19, 2024

@deemp Thanks for the review! You've earned +35 points for this: +25 as a basis; +5 for 876 hits-of-code; +5 for 0 comments. Your running balance is +5.

@0crat
Copy link

0crat commented Jul 19, 2024

@fizruk Thanks for the contribution! You've earned +5 points for this: +20 as a basis; +5 for 876 hits-of-code; -7 for too many hits-of-code (876 >= 100); -15 for way too many hits-of-code (876 >= 400); -5 for 0 comments; +7 to give you at least something. Please, keep them coming. Your running balance is +30.

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.

Custom rules. Iteration 2
3 participants