diff --git a/README.md b/README.md index 68ad4d6ab..06c2a5494 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Result 1 out of 1: ---------------------------------------------------- ``` -#### stdin +#### Input Normalize an expression using a ruleset (See [Rulesets](#rulesets)). Read the expression from stdin. @@ -120,6 +120,11 @@ Result 1 out of 1: ---------------------------------------------------- ``` +Alternatively, the path to the file containing a Phi expression can be passed as a positional argument: +```sh +stack run -- --rules-yaml ./eo-phi-normalizer/test/eo/phi/rules/yegor.yaml test.phi +``` + #### `--chain` Use `--chain` to see numbered normalization steps for each normalization result. @@ -151,6 +156,14 @@ stack run -- --single --rules-yaml ./eo-phi-normalizer/test/eo/phi/rules/yegor.y ⟦ a ↦ ξ.b (c ↦ ⟦ ⟧).d (ρ ↦ ⟦ b ↦ ⟦ c ↦ ∅, d ↦ ⟦ φ ↦ ξ.ρ.c ⟧ ⟧ ⟧) ⟧ ``` +#### Output + +By default, the normalization output will be printed to `stdout`. +The `--output` CLI option (or its shorthand `-o`) can be used to specify the path to the file to which the output will be written instead. +The file will be created if it didn't originally exist. + +This is equivalent to redirecting the output from `stdout` to a file using `>`. + ## Rulesets A ruleset describes a set of user-defined rewriting rules. diff --git a/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml b/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml index 7f075d91b..f8e0285a5 100644 --- a/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml +++ b/eo-phi-normalizer/test/eo/phi/rules/yegor.yaml @@ -47,11 +47,11 @@ rules: ⟦ !B, ρ ↦ ξ.σ ⟧ when: - present_attrs: - attrs: ["σ"] - bindings: ["!B"] + attrs: ['σ'] + bindings: ['!B'] - absent_attrs: - attrs: ["ρ"] - bindings: ["!B"] + attrs: ['ρ'] + bindings: ['!B'] tests: - name: 'Has sigma and no rho' input: '⟦ b ↦ ⟦ ⟧, σ ↦ ⟦ ⟧ ⟧ ' @@ -78,7 +78,7 @@ rules: tests: [] - name: Rule 5 - description: "ξ-dispatch" + description: 'ξ-dispatch' context: current_object: ⟦ !a ↦ ξ.!b, !B ⟧ pattern: | @@ -89,13 +89,13 @@ rules: tests: [] - name: Rule 6 - description: "Accessing an α-binding" + description: 'Accessing an α-binding' pattern: | ⟦ !a ↦ !n, !B ⟧.!a result: | !n(ρ ↦ ⟦ !B ⟧) when: - - nf: ["!n"] + - nf: ['!n'] tests: - name: Should match input: ⟦ hello ↦ ⟦⟧ ⟧.hello @@ -103,17 +103,17 @@ rules: matches: true - name: Shouldn't match input: ⟦ ⟧.hello - output: "" + output: '' matches: false - name: Rule 7 - description: "Application" + description: 'Application' pattern: | ⟦ !a ↦ ∅, !B ⟧(!a ↦ !n) result: | ⟦ !a ↦ !n, !B ⟧ when: - - nf: ["!n"] + - nf: ['!n'] tests: [] - name: Rule 8 @@ -123,10 +123,10 @@ rules: result: | !n.!a when: - - nf: ["!n"] + - nf: ['!n'] - absent_attrs: - attrs: ["!a"] - bindings: ["!B"] + attrs: ['!a'] + bindings: ['!B'] tests: - name: 'Attribute does not exist' input: '⟦ φ ↦ ⟦ ⟧, a ↦ ⟦ ⟧ ⟧.b' @@ -138,11 +138,11 @@ rules: matches: false - name: Rule 9 - description: "Parent application" + description: 'Parent application' pattern: ⟦ ρ ↦ !t, !B ⟧(ρ ↦ !n) result: ⟦ ρ ↦ !n, !B ⟧ when: - - nf: ["!n"] + - nf: ['!n'] tests: [] - name: Rule 10 @@ -150,7 +150,7 @@ rules: pattern: ⟦ !t ↦ !b1, !B1 ⟧(!t ↦ !b2, !B2) result: ⊥ when: - - not_equal: ["!t", "ρ"] + - not_equal: ['!t', 'ρ'] tests: - name: '' input: '⟦ t ↦ ⟦ a ↦ ∅ ⟧ ⟧(t ↦ ⟦ b ↦ ∅ ⟧)' @@ -165,11 +165,11 @@ rules: ⊥ when: - absent_attrs: - attrs: ["!a", "φ", "λ"] - bindings: ["!B"] + attrs: ['!a', 'φ', 'λ'] + bindings: ['!B'] - present_attrs: - attrs: ["ρ", "σ"] - bindings: ["!B"] + attrs: ['ρ', 'σ'] + bindings: ['!B'] tests: - name: 'Accessing nonexistent attribute' input: '⟦ ρ ↦ ⟦ ⟧, σ ↦ ⟦ ⟧ ⟧.x'