Is there an efficient algorithm for finding broken parenthesis in a block of text for the purpose of intellisense error highlighting?
For instance:
function f() {
var a = [1, 2, 3];
if ((a[1] < 1) || (a[0] > 2)) {
console.log((a + 5).toString());
}
}
Where any (
, )
, [
, ]
, {
, or }
character might be dropped or adding in correctly and the correct issue might be highlighted, for instance spotting the specific statement, function, conditional, etc level item causing the issue?
The algorithm is not difficult:
Then you could maybe highlight the unmatched bracket(s).