Skip to content

Commit

Permalink
Merge pull request #113 from objectionary/docs-update
Browse files Browse the repository at this point in the history
Update CLI documentation
  • Loading branch information
aabounegm authored Feb 12, 2024
2 parents 6eafd04 + 6649d2b commit 633e714
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
40 changes: 20 additions & 20 deletions eo-phi-normalizer/test/eo/phi/rules/yegor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ↦ ⟦ ⟧, σ ↦ ⟦ ⟧ ⟧ '
Expand All @@ -78,7 +78,7 @@ rules:
tests: []

- name: Rule 5
description: "ξ-dispatch"
description: 'ξ-dispatch'
context:
current_object: ⟦ !a ↦ ξ.!b, !B ⟧
pattern: |
Expand All @@ -89,31 +89,31 @@ 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
output: ⟦⟧(ρ ↦ ⟦⟧)
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
Expand All @@ -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'
Expand All @@ -138,19 +138,19 @@ 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
description: 'Invalid application'
pattern: ⟦ !t ↦ !b1, !B1 ⟧(!t ↦ !b2, !B2)
result:
when:
- not_equal: ["!t", "ρ"]
- not_equal: ['!t', 'ρ']
tests:
- name: ''
input: '⟦ t ↦ ⟦ a ↦ ∅ ⟧ ⟧(t ↦ ⟦ b ↦ ∅ ⟧)'
Expand All @@ -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'
Expand Down

0 comments on commit 633e714

Please sign in to comment.