I'm writing a messaging system for the users of our site, which implements segmentation to allow for individual messages to target dynamic segments of users. Because a given message's segment definition may contain multiple individual segment matches, it's necessary for the content of the message body also to be segmented. I've attempted to do this by writing what turned out to be a custom lexer/parser (without me even knowing about lexers or parsers) until a chance conversation with a much more experienced programmer suggested I take a look at lexers and parser generators. I've done a bit of research, and found that the PHP native Lime parser generator seems to be my best option, seeing as the code I'm writing is PHP.
I've looked at the grammar file for the calculator example, and at the metagrammar, (in fact, I've spent a few hours analyzing most of the source code) but I'm really having trouble wrapping my head around how to construct even a simple grammar file. Is there anyone who knows of any example grammar files specifically for Lime, as it seems to us its own grammar definition, rather than that of Lemon or any of the other PGs.
Should you be willing and able to provide concrete examples, I'm specifically trying to write conditionals in the format of something like the following:
This is a text block all users will see.
{{IF user.modules.sms}}
This is a text block only visible to users with the sms module enabled
{{/IF}}
{{IF user.modules.anothermodule AND user.previouslogin < (now() - 3600)}}
This is a text block only visible to users with the anothermodule module enabled, whose previous login was more than an hour ago
{{/IF}}
Or just in general, if anyone hase any suggestions on possible other methods of implementing such a feature, I'm open to advice! Just bear in mind it's not possible to use PHP, as the people writing these messages will be project managers and marketers.