@@ -108,20 +108,22 @@ premise1, premise2 -> conclusion
108108For structured terms:
109109- Functions: ` f(a, b) `
110110- Subscripts: ` a[i, j] `
111- - Binary operators: ` a + b `
112- - Unary operators: ` ~ a `
111+ - Binary operators: ` ( a + b) ` (parenthesized)
112+ - Unary operators: ` ( ~ a) ` (parenthesized)
113113
114114### Syntax Comparison Table
115115
116- | Description | Dsp Format (Input ) | Ds Format (Output) |
116+ | Description | Dsp Format (parse input / unparse output ) | Ds Format |
117117| -------------| -------------------| -------------------|
118118| Simple rule | ` a, b -> c ` | ` a\nb\n----\nc ` |
119- | Axiom (no premises) | ` a ` | ` ----\na ` |
119+ | Axiom (parse input) | ` a ` | ` ----\na ` |
120+ | Axiom (unparse output) | ` -> a ` | ` ----\na ` |
120121| Function call | ` f(a, b) -> c ` | ` (function f a b)\n----------------\nc ` |
121122| Subscript | ` a[i, j] -> b ` | ` (subscript a i j)\n-----------------\nb ` |
122123| Binary operator | ` (a + b) -> c ` | ` (binary + a b)\n--------------\nc ` |
123- | Unary operator | ` ~ a -> b ` | ` (unary ~ a)\n-----------\nb ` |
124- | Complex expression | ` (a + b) * c, d[i] -> f(g, h) ` | ` (binary * (binary + a b) c)\n(subscript d i)\n---------------------------\n(function f g h) ` |
124+ | Unary operator (parse input) | ` ~ a -> b ` | ` (unary ~ a)\n-----------\nb ` |
125+ | Unary operator (unparse output) | ` (~ a) -> b ` | ` (unary ~ a)\n-----------\nb ` |
126+ | Complex expression | ` ((a + b) * c), d[i] -> f(g, h) ` | ` (binary * (binary + a b) c)\n(subscript d i)\n---------------------------\n(function f g h) ` |
125127
126128## API Reference
127129
@@ -225,18 +227,11 @@ print(ds)
225227from apyds_bnf import unparse
226228
227229# Unparse multiple rules
228- ds = """ a
229- ----
230- b
231-
232- c
233- ----
234- d"""
230+ ds = " a\n ----\n b\n\n c\n ----\n d"
235231dsp = unparse(ds)
236232print (dsp)
237- # Output:
238- # a -> b
239- # c -> d
233+ # Output: a -> b
234+ # c -> d
240235```
241236
242237### Round-trip Conversion
0 commit comments