Fix tokenizer with multiple nested brackets
Created originally on Bitbucket by stephenrauch (Stephen Rauch)
Was already merged in Bitbucket before import, marked as merged by the import user
Need to keep track of number of closing elements (]) and stop collecting when it reaches 0.