private java.util.Map<Integer, Integer> findUnmatchedBrackets() {
        final Segment text = new Segment();
        final java.util.Stack<Integer> lefts = new java.util.Stack<Integer>();
        final java.util.Map<Integer, Integer> unmatched = new java.util.HashMap<Integer, Integer>();
        final int lineCount = getLineCount();
        
        for (int line = 0; line < lineCount; line++) {
            getLineText(line, text);
            
            for (int i = text.getBeginIndex(); i < text.getEndIndex(); i++) {
                char c = text.array[i];
                if (c == '{') {
                    lefts.push(line);
                } else if (c == '}') {
                    if (lefts.isEmpty()) {
                        unmatched.put(line, 1);
                    } else {
                        lefts.pop();
                    }
                } else if (c == '#') {
                    break; // break line loop
                }
            }
        }
        
        while (!lefts.isEmpty()) {
            unmatched.put(lefts.pop(), 0);
        }
        
        return unmatched;
    }