Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #636 from objectionary/624-old-content-and-comment…
Browse files Browse the repository at this point in the history
…ed-out-code-makes-noise

Update rule files
deemp authored Dec 18, 2024
2 parents 969570a + c47f398 commit b3224b6
Showing 15 changed files with 48 additions and 333 deletions.
6 changes: 4 additions & 2 deletions eo-phi-normalizer/app/Main.hs
Original file line number Diff line number Diff line change
@@ -275,6 +275,8 @@ data CommandParser = CommandParser
, test :: Parser CLI'Test
}

rulesFile = "new.yaml"

commandParser :: CommandParser
commandParser =
CommandParser{..}
@@ -285,7 +287,7 @@ commandParser =
bindingsPath <- bindingsPathOption
pure CLI'MetricsPhi{..}
printRules = do
rulesPath <- optional $ strOption (long "rules" <> short 'r' <> metavar.file <> help [fmt|{metavarName.file} with user-defined rules. If unspecified, yegor.yaml is rendered.|])
rulesPath <- optional $ strOption (long "rules" <> short 'r' <> metavar.file <> help [fmt|{metavarName.file} with user-defined rules. If unspecified, {rulesFile} is rendered.|])
latex <- latexSwitch
compact <- compactSwitch
pure CLI'PrintRules{..}
@@ -602,7 +604,7 @@ main = withCorrectLocale do
-- Temporary hack while rules are not stabilized.
-- Nothing -> return (True, "Yegor's rules (builtin)", [fastYegorInsideOutAsRule])
Nothing -> do
ruleSet :: RuleSet <- decodeThrow $(embedFileRelative "test/eo/phi/rules/new.yaml")
ruleSet :: RuleSet <- decodeThrow $(embedFileRelative [fmt|test/eo/phi/rules/{rulesFile}|])
return (False, ruleSet.title, convertRuleNamed <$> ruleSet.rules)
unless (single || json || latex) $ logStrLn ruleSetTitle
bindingsWithDeps <- case deepMergePrograms (program' : deps) of
2 changes: 1 addition & 1 deletion eo-phi-normalizer/src/Language/EO/Phi/Rules/RunYegor.hs
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ yegorRuleSet :: Yaml.RuleSet
{-# NOINLINE yegorRuleSet #-}
yegorRuleSet =
unsafePerformIO $
Yaml.parseRuleSetFromFile "eo-phi-normalizer/test/eo/phi/rules/yegor.yaml"
Yaml.parseRuleSetFromFile "eo-phi-normalizer/test/eo/phi/rules/new.yaml"

yegorRules :: [NamedRule]
yegorRules = map Yaml.convertRuleNamed (Yaml.rules yegorRuleSet)
2 changes: 1 addition & 1 deletion eo-phi-normalizer/test/Language/EO/Phi/DataizeSpec.hs
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ getProgram inputFile = do
spec :: Spec
spec = do
DataizeTestGroup{..} <- runIO (dataizationTests "test/eo/phi/dataization.yaml")
ruleset <- runIO $ parseRuleSetFromFile "test/eo/phi/rules/yegor.yaml"
ruleset <- runIO $ parseRuleSetFromFile "test/eo/phi/rules/new.yaml"
let rules = map convertRuleNamed ruleset.rules
describe title $
forM_ tests $
3 changes: 1 addition & 2 deletions eo-phi-normalizer/test/Language/EO/Rules/PhiPaperSpec.hs
Original file line number Diff line number Diff line change
@@ -330,8 +330,7 @@ parseTests = Yaml.decodeFileThrow
spec :: Spec
spec =
forM_
[ ("Old Yegor's rules", "test/eo/phi/rules/yegor.yaml")
, ("New Yegor's rules", "test/eo/phi/rules/new.yaml")
[ ("New Yegor's rules", "test/eo/phi/rules/new.yaml")
]
$ \(name, rulesFile) -> do
ruleset <- runIO $ parseRuleSetFromFile rulesFile
3 changes: 1 addition & 2 deletions eo-phi-normalizer/test/Language/EO/YamlSpec.hs
Original file line number Diff line number Diff line change
@@ -31,7 +31,6 @@ import Test.Hspec (Spec)
spec :: Spec
spec =
Test.spec
[ "test/eo/phi/rules/yegor.yaml"
, "test/eo/phi/rules/new.yaml"
[ "test/eo/phi/rules/new.yaml"
, "test/eo/phi/rules/streams.yaml"
]
31 changes: 17 additions & 14 deletions eo-phi-normalizer/test/eo/phi/dataization.yaml
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ tests:
object: |
⟦ a ↦ ⟦ Δ ⤍ 01- ⟧, b ↦ ⟦ Δ ⤍ 01- ⟧, c ↦ ⟦ Δ ⤍ 01- ⟧, d ↦ ⟦ Δ ⤍ 01- ⟧, λ ⤍ Package ⟧
# FIXME: fails
# TODO #636:30min fails
# - name: "cross-reference (1)"
# dependencies: []
# input: |
@@ -176,7 +176,7 @@ tests:
# object: |
# NOT ⟦ x ↦ ⊥, λ ⤍ Package ⟧

# FIXME: fails
# TODO #636:30min fails
# - name: "cross-reference (2)"
# dependencies: []
# input: |
@@ -185,7 +185,7 @@ tests:
# object: |
# NOT ⟦ x ↦ ⊥, λ ⤍ Package ⟧

# FIXME: fails
# TODO #636:30min fails
# - name: "cross-reference + dispatch (1)"
# dependencies: []
# input: |
@@ -194,7 +194,7 @@ tests:
# object: |
# NOT ⟦ x ↦ ⊥, λ ⤍ Package ⟧

# FIXME: fails
# TODO #636:30min fails
# - name: "cross-reference + dispatch (1)"
# dependencies: []
# input: |
@@ -203,7 +203,7 @@ tests:
# object: |
# NOT ⟦ x ↦ ⊥, λ ⤍ Package ⟧

# FIXME: fails
# TODO #636:30min fails
# - name: "cross-reference + dispatch (2)"
# dependencies: []
# input: |
@@ -212,7 +212,7 @@ tests:
# object: |
# NOT ⟦ x ↦ ⊥, λ ⤍ Package ⟧

# FIXME: fails
# TODO #636:30min fails
# - name: "cross-reference + dispatch (3)"
# dependencies: []
# input: |
@@ -221,7 +221,7 @@ tests:
# object: |
# NOT ⟦ x ↦ ⊥, λ ⤍ Package ⟧

# FIXME: fails
# TODO #636:30min fails
# - name: "interleaving ρ and other dispatches"
# dependencies: []
# input: |
@@ -309,7 +309,7 @@ tests:
output:
bytes: "00-"

# Missing int tests: div
# TODO #636:30min Missing int tests: div

- name: "bitwise and"
dependencies:
@@ -373,7 +373,7 @@ tests:
output:
bytes: "01-"

# Missing bytes tests: or, xor, slice, concat
# TODO #636:30min Missing bytes tests: or, xor, slice, concat

- name: "float times and plus (raw bytes)"
dependencies:
@@ -413,7 +413,7 @@ tests:
output:
object: "69.42"

# Missing float tests: gt, div
# TODO #636:30min Missing float tests: gt, div

- name: "string slice (raw bytes)"
dependencies:
@@ -478,7 +478,10 @@ tests:
output:
object: "11" # == 11

# Missing malloc tests: (all)
# Missing cage tests: (all)
# Missing io tests: (all)
# Other missing tests: dataized, error, seq, as_phi, rust, try
# TODO #636:30min Missing malloc tests: (all)

# TODO #636:30min Missing cage tests: (all)

# TODO #636:30min Missing io tests: (all)

# TODO #636:30min Other missing tests: dataized, error, seq, as_phi, rust, try
6 changes: 3 additions & 3 deletions eo-phi-normalizer/test/eo/phi/rules/new.yaml
Original file line number Diff line number Diff line change
@@ -31,7 +31,8 @@ rules:
⌈ !b , ⟦ !τ ↦ !b, !B ⟧ ⌉(ρ ↦ ⟦ !τ ↦ !b, !B ⟧)
when:
- nf: '!b'
- nf: '⟦ !B ⟧' #TODO: change the condition, every object in !B should be in the nf
# TODO #636:30min Change the condition, every object in !B should be in the nf
- nf: '⟦ !B ⟧'
tests:
- name: 'Contextualization changes ξ'
input: ⟦ a ↦ ξ ⟧.a
@@ -80,7 +81,6 @@ rules:
output: ['⟦ a ↦ ⟦ b ↦ ⟦ a ↦ ⟦ b ↦ ∅ ⟧ (b ↦ ξ) ⟧ ⟧ ().a ⟧']
- name: Phi Paper - Example E1
input: ⟦ k ↦ ⟦ x ↦ ξ.t, t ↦ ∅ ⟧(t ↦ ⟦ρ ↦ ⟦⟧⟧) ⟧
# output: ['⟦ k ↦ ⟦ x ↦ ξ.t, t ↦ ⟦ρ ↦ ⟦⟧⟧ ⟧() ⟧']
output: ['⟦ k ↦ ⟦ t ↦ ⟦ρ ↦ ⟦⟧⟧, x ↦ ξ.t ⟧() ⟧']
- name: Phi Paper - Example E4 - dispatch on y
input: ⟦ k ↦ ⟦ x ↦ ∅, y ↦ ξ.x ⟧(x ↦ ⟦ρ ↦ ⟦⟧⟧).y ⟧
@@ -124,7 +124,7 @@ rules:
input: ⟦ m ↦ ⟦ x ↦ ξ.t, φ ↦ ⟦ t ↦ ⟦⟧ ⟧ ⟧.t(ρ ↦ ⟦ x ↦ ξ.t, φ ↦ ⟦ t ↦ ⟦⟧ ⟧ ⟧) ⟧
output: ['⟦ m ↦ ⟦ x ↦ ξ.t, φ ↦ ⟦ t ↦ ⟦⟧ ⟧ ⟧.φ.t(ρ ↦ ⟦ x ↦ ξ.t, φ ↦ ⟦ t ↦ ⟦⟧ ⟧ ⟧) ⟧']

# there's no B2 in the result
# TODO #636:30min There's no B2 in the result
- name: STAY
description: 'Application of a ρ-binding when ρ already exists'
pattern: |
288 changes: 0 additions & 288 deletions eo-phi-normalizer/test/eo/phi/rules/yegor.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/lib.sh
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ PIPELINE_EO_PHI_NORMALIZER_DATA_DIR="$PIPELINE_EO_PHI_NORMALIZER_DIR/data"
PIPELINE_REPORT_DIR="$PWD/report"
PIPELINE_EO_YAML_DIR="$PIPELINE_DIR/eo-yaml"

PIPELINE_EO_PHI_NORMALIZER_RULES="" # "--rules '$PIPELINE_EO_PHI_NORMALIZER_DIR/test/eo/phi/rules/yegor.yaml'"
PIPELINE_EO_PHI_NORMALIZER_RULES="" # "--rules '$PIPELINE_EO_PHI_NORMALIZER_DIR/test/eo/phi/rules/new.yaml'"

SCRIPTS_DIR="$PWD_DIR/scripts"
PIPELINE_SCRIPT="$SCRIPTS_DIR/pipeline.sh"
10 changes: 5 additions & 5 deletions site/docs/src/eo-phi-normalizer/dataize.md
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ Similar to `--rules` for the `transform` subcommand, this argument accepts the p
If the `--chain` argument is passed, all the intermediate steps of normalization + dataization are printed to the console (or the output file if chosen).

```$ as console
eo-phi-normalizer dataize --chain --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer dataize --chain --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -1299,7 +1299,7 @@ Can be used multiple times to inject multiple dependencies.
Applies the normalization+dataization process recursively until it reaches bytes or no longer modifies the object (stalls).

```$ as console
eo-phi-normalizer dataize --recursive --rules eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer dataize --recursive --rules eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -1429,7 +1429,7 @@ Can be combined with `--chain` to print all the intermediate steps of both norma
Enable an atom by name.

```$ as console
eo-phi-normalizer dataize --minimize-stuck-terms --recursive --enable-atom "Lorg_eolang_dataized" --rules eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer dataize --minimize-stuck-terms --recursive --enable-atom "Lorg_eolang_dataized" --rules eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -1454,7 +1454,7 @@ eo-phi-normalizer dataize --minimize-stuck-terms --recursive --enable-atom "Lorg
Disable an atom by name.

```$ as console
eo-phi-normalizer dataize --minimize-stuck-terms --recursive --disable-atom "Lorg_eolang_dataized" --rules eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer dataize --minimize-stuck-terms --recursive --disable-atom "Lorg_eolang_dataized" --rules eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -1479,7 +1479,7 @@ eo-phi-normalizer dataize --minimize-stuck-terms --recursive --disable-atom "Lor
If no argument is given for the input file, `stdin` is consumed until `EOF`.

```$ as console
cat celsius.phi | eo-phi-normalizer dataize --recursive --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml
cat celsius.phi | eo-phi-normalizer dataize --recursive --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml
```

```console
2 changes: 1 addition & 1 deletion site/docs/src/eo-phi-normalizer/print-rules.md
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ Available options:

### Default version

The command below prints to the console rules from `yegor.yaml`, listing each condition of the rules on a separate line.
The command below prints to the console rules from [new.yaml](https://github.com/objectionary/eo-phi-normalizer/blob/master/eo-phi-normalizer/test/eo/phi/rules/new.yaml), listing each condition of the rules on a separate line.

![rules-latex](../media/print-rules-tex.png)

16 changes: 8 additions & 8 deletions site/docs/src/eo-phi-normalizer/rewrite.md
Original file line number Diff line number Diff line change
@@ -53,13 +53,13 @@ Available options:

### `--rules FILE`

Normalize a 𝜑-expression from `celsius.phi` using the rules from a given file (e.g. [yegor.yaml](#yegoryaml)).
Normalize a 𝜑-expression from `celsius.phi` using the rules from a given file.

The output may contain multiple numbered results that correspond to different possible rule application sequences
(even if the final result is the same).

```$ as console
eo-phi-normalizer rewrite --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer rewrite --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -103,7 +103,7 @@ Result 1 out of 1:
Use `--chain` to see numbered normalization steps for each normalization result.

```$ as console
eo-phi-normalizer rewrite --chain --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer rewrite --chain --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -190,7 +190,7 @@ This is the 2nd possible chain of normalizing rewritings:
### `--json`

```$ as json
eo-phi-normalizer rewrite --json --chain --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer rewrite --json --chain --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```json
@@ -210,7 +210,7 @@ eo-phi-normalizer rewrite --json --chain --rules ./eo-phi-normalizer/test/eo/phi
### `--single`

```$ as console
eo-phi-normalizer rewrite --single --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer rewrite --single --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -233,7 +233,7 @@ eo-phi-normalizer rewrite --single --rules ./eo-phi-normalizer/test/eo/phi/rules
### `--single --single-line`

```$ as console
eo-phi-normalizer rewrite --single --single-line --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer rewrite --single --single-line --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -243,7 +243,7 @@ eo-phi-normalizer rewrite --single --single-line --rules ./eo-phi-normalizer/tes
### `--single` `--json`

```$ as console
eo-phi-normalizer rewrite --single --json --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml celsius.phi
eo-phi-normalizer rewrite --single --json --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml celsius.phi
```

```console
@@ -282,7 +282,7 @@ Can be used multiple times to inject multiple dependencies.
### `FILE` not specified (read from stdin)

```$ as console
cat celsius.phi | eo-phi-normalizer rewrite --single --json --rules ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml
cat celsius.phi | eo-phi-normalizer rewrite --single --json --rules ./eo-phi-normalizer/test/eo/phi/rules/new.yaml
```

```console
4 changes: 2 additions & 2 deletions site/docs/src/eo-phi-normalizer/test.md
Original file line number Diff line number Diff line change
@@ -21,15 +21,15 @@ Available options:
### Run tests in a file

```console
eo-phi-normalizer test --rules eo-phi-normalizer/test/eo/phi/rules/yegor.yaml
eo-phi-normalizer test --rules eo-phi-normalizer/test/eo/phi/rules/new.yaml
```

<!--
The command output is modified to make documentation generation reproducible.
The full command is hidden to not show unnecessary details in the documentation.
`$ eo-phi-normalizer test --rules eo-phi-normalizer/test/eo/phi/rules/yegor.yaml | sed -e 's/\(Finished in\) \([0-9]\.[0-9]\+\)/\1 0.0062/'` as console -->
`$ eo-phi-normalizer test --rules eo-phi-normalizer/test/eo/phi/rules/new.yaml | sed -e 's/\(Finished in\) \([0-9]\.[0-9]\+\)/\1 0.0062/'` as console -->

```console
User-defined rules unit tests
2 changes: 1 addition & 1 deletion site/docs/src/quick-start.md
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ Dataize the program recursively.
```$ as console
eo-phi-normalizer dataize \
--recursive \
--rules eo-phi-normalizer/test/eo/phi/rules/yegor.yaml \
--rules eo-phi-normalizer/test/eo/phi/rules/new.yaml \
--dependency-file 'eo-phi-normalizer/data/0.38.0/org/eolang/float.phi' \
--dependency-file 'eo-phi-normalizer/data/0.38.0/org/eolang/bytes.phi' \
celsius.phi
4 changes: 2 additions & 2 deletions site/docs/src/user-defined-rules.md
Original file line number Diff line number Diff line change
@@ -12,9 +12,9 @@ Currently, the `eo-phi-normalizer` supports rules defined in an unpublished pape

![Rules](media/rules.jpg)

## yegor.yaml
## new.yaml

The rules are defined in [yegor.yaml](https://github.com/objectionary/eo-phi-normalizer/blob/master/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml).
The rules are defined in [new.yaml](https://github.com/objectionary/eo-phi-normalizer/blob/master/eo-phi-normalizer/test/eo/phi/rules/new.yaml).

Each rule has the following structure:

0 comments on commit b3224b6

Please sign in to comment.