# Miscellaneous string parser definition file extending user input. # The purpose of this file is to extend the english-language parsing # system of CoffeeMud. This file is also intended for use as the # user-input translation file for internationalization, mainly through # the command-pre-processor section of this file. # # This file is divided into three sections: the command pre-processor, which # allows you to parse and manipulate command strings entered by players # before the main coffeemud parser gets ahold of it, the item pre-processor, # which allows you to parse the names of items, mobs, exits before they # are searched for in inventories and on the ground, and the failed item # processor, which allows you to take another try with the names of items # and mobs when a preliminary search has failed to find anything matching # in inventories or on the ground. # # There several commands defined for each section: # replacewhole "string literal" with "string literal" # This command will replace the first string with the second string # only if the entire translatable input string is equal to the first # string argument. This is easily the best performing command for # doing translations, and should be preferred above others wherever # possible and practical. # replace "regular expression pattern" with "replacement pattern" # This command will search for the given reguar expression pattern in # the string. If it is found, the string following the with clause # will be used to change the string to something else. Regular # expressions are exactly as they are defined in the Java API. # Replacement expressions may include literals, or a slash followed # by a number to insert Java "capturing groups" from the search # expression. The double quotes around the expressions are required. # You may escape a quote with a backslash to include it in your expressions. # replaceall "sub-string literal" with "string literal" # This command will search for all instances of the given sub-string in the # translatable input string and replace them with the given string literal. This # command is good for catching references to hard coded named things, such # as spell names and the like. It performs much better than the normal replace # command, but is still far more of a performance hit than replacewhole. # ignorewhole "string literal" # This command will cause the entire string to be ignored by the translator # if it matches the given string. This is easily the best performing ignore for # ignoring translation strings, and should be preferred above ignore and # ignoreall wherever possible and practical. # ignore "regular expression pattern" # This command will search for the given reguar expression pattern in # the string. If it is found, the entire string is ignored by the translator. # Regular expressions are exactly as they are defined in the Java API. # This is the worst performing ignore command, but also the most versatile. # Still use it sparingly, be careful with your regular expression syntax, # and read the information about escape sequences below. # ignoreall "sub-string literal" with "string literal" # This command will search for an instance of the given sub-string in the # translatable string and, if found, ignore then entire translatable input string. # This command is good for catching references to hard coded named things, such # as spell names and the like. It performs much better than the normal ignore # command, but is still far more of a performance hit than ignorewhole. # autoignore <max-string-length> # This command will cause any translatable input strings which were not modified by # the translator in any way to be added automatically to the section list as # a "IGNOREWHOLE" command, thus preventing it from being re-parsed the next # time it is encountered. Because users can type anything, you should be careful # with this command. If it is used, your file should be re-examined regularly # and the newly added IGNOREWHOLE strings changed to some other command. # define "variable string" as "replacement string" # This command is used to define strings which will be replaced inside of # other commands. A variable definition will apply only to the section in # which it is defined. The replacement will be applied to both expressions # and replacement strings in the REPLACE command, as well as in the # replacement string of other DEFINE commands. This command may be placed # before the first section to make it "global" to all sections. # # Escape characters: # In the commands IGNOREALL/REPLACEALL and IGNOREWHOLE, REPLACEWHOLE, # the only characters which must be escaped are " with \", tabs with \t, \ with \\, # and cr/lf \n\r. # For the REPLACE/IGNORE commands, the regular expression parameter must have all # special regular expression characters escaped in order to be matched. Those include: # . ( ) { } [ ] ^ $ ? * + | # # The command pre-processor has a few extra features for the replace-like commands. One # is that individual command words will be pre-parsed and separated by tabs, which # may be represented in your expressions by the \t character. The replacement # expression may contains \n characters to denote that the command should be # separated into two or more other commands. Be sure to maintain the \t structure # of the string in order for CoffeeMud to properly parse your commands. [command-pre-processor] define "{COMMANDS}" as "get|put|wear|wield|hold|open|close|eat|lock|unlock|pull|push|sniff|buy|sell|look" define "{1PARM_CMDS}" as "wear|wield|hold|open|close|eat|lock|unlock|pull|push|sniff|buy|sell|read" define "{EXIT_CMDS}" as "open|close|look|lock|unlock" # first, normalize diff counters with cm counters replace "(^(?>{COMMANDS})\t)(.+\t)#(\d+)([a-zA-Z].*)" with "\1\2\3.\4" #replace "(.+\t)([a-zA-Z]+)#(\d+)(.*)" with "\1\3.\2\4" # This wreaks havoc with room numbers! replace "(^(?>{COMMANDS})\t)(.+\t)first\t([a-zA-Z].*)" with "\1\21.\3" replace "(^(?>{COMMANDS})\t)(.+\t)second\t([a-zA-Z].*)" with "\1\22.\3" replace "(^(?>{COMMANDS})\t)(.+\t)third\t([a-zA-Z].*)" with "\1\23.\3" replace "(^(?>{COMMANDS})\t)(.+\t)fourth\t([a-zA-Z].*)" with "\1\24.\3" replace "(^(?>{COMMANDS})\t)(.+\t)fifth\t([a-zA-Z].*)" with "\1\25.\3" replace "(^(?>{COMMANDS})\t)(.+\t)sixth\t([a-zA-Z].*)" with "\1\26.\3" replace "(^(?>{COMMANDS})\t)(.+\t)seventh\t([a-zA-Z].*)" with "\1\27.\3" replace "(^(?>{COMMANDS})\t)(.+\t)eighth\t([a-zA-Z].*)" with "\1\28.\3" replace "(^(?>{COMMANDS})\t)(.+\t)ninth\t([a-zA-Z].*)" with "\1\29.\3" # special match replace "^it\tputs\t(.+)\tin\t(.+)" with "put\t\1\tfrom\t\2" # command word expansions -- this functionality is normally handled by the base parser, # but in this case, we MUST expand the words so that they can match the others # this is also how we can easily define shortcut preferences. replace "^(?>ge|g)\t(.+)" with "get\t\1" replace "^pu\t(.+)" with "put\t\1" replace "^(?>ope|op)\t(.+)" with "open\t\1" replace "^(?>clos|clo|cl)\t(.+)" with "close\t\1" replace "^bu\t(.+)" with "buy\t\1" replace "^ea\t(.+)" with "eat\t\1" replace "^sel\t(.+)" with "sell\t\1" replace "^(?>empt|emp|em)\t(.+)" with "empty\t\1" replace "^(?>unloc|unlo|unl|un)\t(.+)" with "unlock\t\1" replace "^(?>loo|lo|l)\t(.+)" with "look\t\1" replace "^loc\t(.+)" with "lock\t\1" replace "^(?>pul|pu)\t(.+)" with "pull\t\1" replace "^pus\t(.+)" with "push\t\1" replace "^(?>snif|sni)\t(.+)" with "sniff\t\1" replace "^(?>wea|we)\t(.+)" with "wear\t\1" replace "^(?>wiel|wie|wi)\t(.+)" with "wield\t\1" replace "^(?>hol|ho)\t(.+)" with "hold\t\1" # command word separating and normalization replace "^place(\t.+)" with "put\1" replace "^open\tup(\t.+)" with "open\1" replace "^look\tin(\t.+)" with "look\1" replace "^look\tat(\t.+)" with "look\1" replace "^look\tinside(\t.+)" with "look\1" replace "(^(?>{COMMANDS})\t)(.+\t)and\t((?>hold|open|close|eat|lock)\t)it\tup$" with "\1\2\n\3\2" replace "(^(?>{COMMANDS})\t)(.+\t)and\t((?>{1PARM_CMDS})\t)it$" with "\1\2\n\3\2" replace "(^(?>{COMMANDS})\t)(.+\t)and\t((?>{COMMANDS})\t)it(\t.*)" with "\1\2\n\3\2\4" replace "(^(?>{COMMANDS})\t)(.+\t)and\t((?>{COMMANDS})\t)(.+)" with "\1\2\n\3\4" replace "^put\t(.+)\tinside\t(.+)" with "put\t\1\tfrom\t\2" replace "^put\t(.+)\tin\t(.+)" with "put\t\1\tfrom\t\2" replace "(^(?>{EXIT_CMDS})\t)(||.*\t)north($||\t.*)" with "\1north" replace "(^(?>{EXIT_CMDS})\t)(||.*\t)south($||\t.*)" with "\1south" replace "(^(?>{EXIT_CMDS})\t)(||.*\t)east($||\t.*)" with "\1east" replace "(^(?>{EXIT_CMDS})\t)(||.*\t)west($||\t.*)" with "\1west" replace "(^(?>{EXIT_CMDS})\t)(||.*\t)northwest($||\t.*)" with "\1northwest" replace "(^(?>{EXIT_CMDS})\t)(||.*\t)southwest($||\t.*)" with "\1southwest" replace "(^(?>{EXIT_CMDS})\t)(||.*\t)northeast($||\t.*)" with "\1northeast" replace "(^(?>{EXIT_CMDS})\t)(||.*\t)southeast($||\t.*)" with "\1southeast" # multi-item gets and puts with from replace "(^(?>get|put)\t)(.+),\tand\t(.+\t)(from\t.+)" with "\1\2\t\4\n\1\3\4" replace "(^(?>get|put)\t)(.+),\t(.+)(\tfrom\t.+)" with "\1\2\4\n\1\3\4" replace "(^(?>get|put)\t)(.+\t)and\t(.+\t)(from\t.+)" with "\1\2\4\n\1\3\4" replace "(^(?>get|put)\t)(\d+\..+\t)(\d+\..+\t)(from\t.+)" with "\1\2\4\n\1\3\4" # multi-items without from replace "(^(?>{COMMANDS})\t)(.+),\tand\t(.+)" with "\1\2\n\1\t\3" replace "(^(?>{COMMANDS})\t)(.+),\t(.+)" with "\1\2\n\1\3" replace "(^(?>{COMMANDS})\t)(.+)\tand\t(.+)" with "\1\2\n\1\3" replace "(^(?>{1PARM_CMDS})\t)(\d+\..+\t)(\d+\..+)" with "\1\2\n\1\3" replace "(^(?>get|put)\t)(\d+\..+\t(?<!from\t))(\d+\..+\t(?<!from\t))(\d+\..+)" with "\1\2\n\1\3\n\1\4" # a little final article clean up replace "(^(?>{COMMANDS})\t)the\t(.+)" with "\1\2" replace "(^(?>{COMMANDS})\t)a\t(.+)" with "\1\2" replace "(^(?>{COMMANDS})\t)an\t(.+)" with "\1\2" replace "(^(?>{COMMANDS})\t)that\t(.+)" with "\1\2" replace "(^(?>get|put)\t.+\tfrom\t)the\t(.+)" with "\1\2" replace "(^(?>get|put)\t.+\tfrom\t)a\t(.+)" with "\1\2" replace "(^(?>get|put)\t.+\tfrom\t)an\t(.+)" with "\1\2" replace "(^(?>get|put)\t.+\tfrom\t)that\t(.+)" with "\1\2" # uncomment the below and remove all the above replace lines to begin accumulating user commands in this file. # autoignore 100 [item-pre-processor] [item-fail-processor]