# Miscellaneous string parser definition file for the English language. # # This file is divided into three sections: the command 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. # # At the moment, there are only two commands defined for each section: # 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. # 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". # # The command pre-processor has a few extra features for the replace command. 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" [item-pre-processor] [item-fail-processor]