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

Update CLI documentation #113

Merged
merged 4 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 All @@ -139,6 +144,14 @@ Result 1 out of 1:
----------------------------------------------------
```

#### 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