Closed dcsan closed 9 years ago
Just write them as lowercase. Part of the usefulness of a syntax checker is also to prevent against accidental mistakes, like a user carelessly copying/pasting text from elsewhere (for example, the parser will also complain loudly if it sees a character at the beginning of a line that it doesn't understand to be a command symbol, or a line that has a command symbol but nothing else. This was actually helpful when making an AIML-to-RiveScript converter to detect uncaught line break issues that were messing with the formatting of the output).
If the code automatically corrects the syntax errors (by lowercasing it), that could inadvertently mask a deeper issue with the trigger. I'd rather the syntax checking be strict and alert the user to fix the line of text than to silently mask potential errors.
I don't think this is much different than AIML forcing all patterns to be in all caps. I chose all lowercase because forcing the coder to turn on caps lock or press down on the shift key to type a whole sentence doesn't make a lot of sense, and the only down side is the grammatical issues with "i" not being capitalized which isn't that bad imho.
in our case we're working with a lot of non-technical content authors, so this often seems to cause problems... additionally our parser runs on the server, so catching errors there and sending them back to the client, is a lot more work to implement...
In that case, you can convert it on your end (when getting them from the authors) by using a regexp, like:
perl -pe 's/^(\s*\+ .+)$/\L$1\E/g' filename.rive
That would read filename.rive
, replace all + lines with lowercased versions and print them. Here's an example (of doing the opposite, setting them to uppercase) to see how it works (on the default admin.rive):
$ perl -pe 's/^(\s*\+ .+)$/\U$1\E/g' admin.rive
// Administrative functions.
+ SHUTDOWN{WEIGHT=10000}
* <id> eq <bot master> => Shutting down... <call>shutdown</call>
- {@botmaster only}
+ BOTMASTER ONLY
- This command can only be used by my botmaster. <id> != <bot master>
> object shutdown perl
my ($rs) = @_;
# Shut down.
exit(0);
< object
I often see errors from our non-tech editors like
basically they'll use a capital "I" instead of i
since the triggers have to be lowercase, they're basically case-insensitive. can't the text just be converted to lowercase automatically?
I did try adding a rule like
! sub I = i
but it doesn't seem to take affect at the right point in the flow.