views:

40

answers:

0

for now I have a pretty simple way of parsing out some commands through actionscript.

I'm using regexp to find tags, commands and operands using...

+key_word+  // any text surrounded by +
[ifempty +val_1+]+val_2+[/ifempty]  //simple conditional
[ifisnot={`true,yes`} +ShowTitle+]+val_3+[/ifisnot]  // conditional with operands

my current algorithm matches the opening tag[**] with the first closing tag [/**] even though it doesn't match. Which means that I could not do something like [ifempty +val_2+][ifnotempty +val_2]+val_3+[/ifnotempty]+val_4+[/ifempty] - essentially putting one conditional inside another one.

I'm using an inline way of parsing that splits the string into an array of strings based on this regexp \[[^\/](?:[^\]])*\](?:[^\]])*\[\/(?:[^\]])*\]

can anyone suggest a more robust algorithm with a more robust parsing convention/standard? especially for as3.