Marcel van Lohuizen | ea40e66 | 2018-12-11 18:07:49 +0100 | [diff] [blame] | 1 | package trim |
| 2 | |
| 3 | foo <Name>: { |
| 4 | _value: string |
| 5 | |
| 6 | a: 4 |
| 7 | b: string |
| 8 | d: 8 |
| 9 | e: "foo" |
Marcel van Lohuizen | 76b92b5 | 2018-12-16 10:47:03 +0100 | [diff] [blame^] | 10 | f: ">> \( _value) <<" |
Marcel van Lohuizen | ea40e66 | 2018-12-11 18:07:49 +0100 | [diff] [blame] | 11 | n: 5 |
| 12 | |
| 13 | list: ["foo", 8.0] |
| 14 | |
| 15 | struct: {a: 3.0} |
| 16 | |
| 17 | sList: [{a: 8, b: string}, {a: 9, b: "foo" | string}] |
| 18 | rList: [{a: "a"}] |
| 19 | rcList: [{a: "a", c: b}] |
| 20 | |
| 21 | t <Name>: { |
| 22 | x: 0..5 |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | foo bar: { |
| 27 | _value: "here" |
| 28 | |
| 29 | a: 4 |
| 30 | b: "foo" |
| 31 | c: 45 |
| 32 | e: string |
| 33 | f: ">> here <<" |
| 34 | |
| 35 | // The template does not require that this field be an integer (it may be |
| 36 | // a float), and thus this field specified additional information and |
| 37 | // cannot be removed. |
| 38 | n: int |
| 39 | |
| 40 | struct: {a: 3.0} |
| 41 | |
| 42 | list: ["foo", float] |
| 43 | |
| 44 | sList: [{a: 8, b: "foo"}, {b: "foo"}] |
| 45 | rList: [{a: string}] |
| 46 | rcList: [{a: "a", c: "foo"}] |
| 47 | } |
| 48 | |
| 49 | foo baz: {} |
| 50 | |
| 51 | foo multipath: { |
| 52 | t <Name>: { |
| 53 | // Combined with the other template, we know the value must be 5 and |
| 54 | // thus the entry below can be eliminated. |
| 55 | x: 5..8 |
| 56 | } |
| 57 | |
| 58 | t u: { |
| 59 | x: 5 |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // TODO: top-level fields are currently not removed. |
| 64 | group: { |
Marcel van Lohuizen | 76b92b5 | 2018-12-16 10:47:03 +0100 | [diff] [blame^] | 65 | comp "\(k)": v for k, v in foo |
Marcel van Lohuizen | ea40e66 | 2018-12-11 18:07:49 +0100 | [diff] [blame] | 66 | |
| 67 | comp bar: { |
| 68 | a: 4 |
| 69 | aa: 8 // new value |
| 70 | } |
| 71 | |
| 72 | comp baz: {} // removed: fully implied by comprehension above |
Marcel van Lohuizen | 76b92b5 | 2018-12-16 10:47:03 +0100 | [diff] [blame^] | 73 | } |