Hi Alex,
My vote is against native support in P because the majority of
applications would find existing string operators (substring
searching, essentially) and application-specific interfaces
sufficient. (BTW, I will add a length() and index() string functions
to Core).
These would be used a lot in a rules language.
Can you give a couple of examples where REs would be essential, given
available substring searching operators _and_ ability of
application-specific modules to split application objects (e.g., HTTP
headers) into semantically valid but smaller pieces for you?
I suppose if you have modules that can process REGEXs as quickly, it should be
all right.
Section 2. Escape sequences for the grammar (from C++):
escape-sequence:
basic-escape-sequence/
octal-escape-sequence/
hex-escape-sequence
Yeah, and we would need to add a universal-character-name as a part of
string-char or escape-sequence. This all looks kind of heavy. Is there
a simpler, but still complete solution? Replacing support for
octal-escape-sequence and hex-escape-sequence with
universal-character-name? What does XML have to offer here?
Sorry, I am not well versed in this space :-(
But, I have tried to write up a few (simple) examples for the examples to-do:
Example1: (edited from the current version)
Http := import "http://ietf.org/opes/rules/p/HTTP";
// Is the requested web document our home page?
isHome := request.uri.looksLikeHome();
// Does the user send us a specific cookie?
cookie := makeHeader("Cookie", "sew=23");
haveCookie := request.headers.have(cookie);
if (isHome and haveCookie) {
Services := import "http://ietf.org/opes/rules/p/Services";
service := Services.findOne("opes://local.net/add-lcl-content");
service.clientIp(request.clientIp);
Services.applyOne(service);
}
Example 2: HTTP header anonymization
Http := import "http://ietf.org/opes/rules/p/HTTP";
haveClientAddress := defined request.getRemoteAddress();
haveUserAgentInfo := defined request.getUserAgent();
if(haveClientAddress and haveUserAgentInfo )
{
Services := import "http://ietf.org/opes/rules/p/Services";
service := Services.findOne("opes://anon.net/anonymize");
Services.applyOne(service, request.header);
}
//forward the request to the content server
request.forwardRequest();
Example 3: SMTP Email filter
Smtp := import "http://ietf.org/opes/rules/p/SMTP";
haveAttachment := message.header.getContentType() equal
"multipart/mixed"
if(haveAttachment)
{
Services := import "http://ietf.org/opes/rules/p/Services";
service := Services.findOne("opes://norton.com/VirusCheck");
Services.applyOne(service, message.body);
}
if ( currentUserEmail equal message.header.getSenderEmail() )
{
message.returnToSender("Your attachment had a virus.");
}
else
{
message.replaceBody("The message had a virus infected
attachment.");
}
Example 4: User-Agent-based content transcoding - This might be a more
complicated example. In case you are interested, I can write this up. Being a
telecom industry person, this would be more relevant for my applications.
Regards,
Anwar