Given type input
a { b c d { e f } g }
I want to parse it into one token at a time (letter or parenthesis). When I press the first closing bracket }, I need to know how many elements have been since the last opening bracket (e and f = 2). And then when I hit one after him, I need 4 (b, c, d, g).
It’s easy to grab 1 on 1 markers, but ... I don’t know how to count them. I was thinking about Stack<int>, but I can’t change the top element to enlarge it?
source
share