sancarn / Extended_MapBasic

This is an Open Source project. We are developing a powerful extension for the MapBasic Window in Pitney Bowes' MapInfo. The extension will give users the ability to compile on demand from the MapBasic Window. Further extensions may include custom MapBasic functions to accomplish common tasks. This project is still very much WIP
MIT License
1 stars 0 forks source link

Find "If ... End If" blocks avoiding "Catastrophic Backtracking" #4

Open sancarn opened 8 years ago

sancarn commented 8 years ago

Algorithm:

Use "\bIf\s+.+\s+Then" to find "If ... then" Use "\bEnd\s+If\b" to find End If.

E.G.

Positions of END: 170, 234, 746, 754 Positions of IFS: 115, 181, 383, 633

Concatenate e or i depending on which list they're in. Then merge lists: 170E, 234E, 746E, 754E, 115I, 181I, 383I, 633I

Sort list: 115I, 170E, 181I, 234E, 383I, 633I, 746E, 754E

This is our nested if ... end if structure.