Efficient analysis of complex diagrams using constraint-based parsing