Previous chapter ⋅ Full source code
Our error reporting is quite poor, the only thing we know for sure is either brackets are balanced or not.
We can start with case splitting between mismatched and missing brackets:
`li` "[ERROR] Mistmached brackets..."
`lv` "[ERROR] Some missing bracket..."
`lv` "[VALID] Everything is fine!"
Still not good enough! We need more information. Let’s break down reporting for each type one by one.
mismatch (These opened closed) = "[ERROR] Mismatched bracket shapes - "
`yokl` Prior `ha` State `ha` Event `ha` push `hv___'he` List
`ha__` Next `ha` Glyph `ha` Symbol `ha` Bracket `ha` Opened `hv` opened
`ha__` Next `ha` Caret `hv` Space
`hv__` Last `ha` Glyph `ha` Symbol `ha` Bracket `ha` Closed `hv` closed
missing bracket = "[ERROR] Missing bracket - "
`yokl` Prior `ha` State `ha` Event `ha` push
`hv___'he` intro @_ @List `ha` Glyph `ha`Symbol `ha` Bracket `hv` bracket
balance _ = by `hv` Empty @List `lu` "[VALID] Everything is seem to be good!"
All what is left is just put these expression on their places:
mismatch `la` missing `la` balance