Bracket Matching by murky-satyr

stdin linesDo:[:x|F:=0.O:=''subStrings.
x doWithIndex:[:c :i|(P:='({[<)}]>'indexOf:c)<5and:[O add:4+P];or:[(O size=0or:[O removeLast~=P])and:[F>0or:[F:=i]]]].M:='yes'.F+O size=0or:[N:=#EOL.F=0or:[N:=x copyFrom:F].M:='failed at: ',N].M displayNl]

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top