[Coldstuff] Parsers

Grimslayde grimslayde at sbcglobal.net
Tue Dec 31 16:57:51 MST 2002


Heya Gary,
    Parsers aren't so bad to work with. The chargen_parser is a great
example of how it can work. Basically, once you add a parser onto that
person it is slapped into their parser list stored... oh somewhere down in
the lineage of $user. Any input from a connection gets passed through these
parsers in order of the parser's priority - the lower the more important.
The parser is only used as a reference, by the way, it isn't tied to the
object using it beyond that... well, not unless you code it otherwise.

    All you have to do is set up a parse method on your parser. What I did
for my character generation process was slap a variable on $player called
pgen_data. This is a dictionary that stores all the miscellanious tidbits of
info used by the parser I cooked up. Each time a call was made to the
parser, it checked that pgen_data to see what stage the user was on. Thus,
if the player was on race-selection, the pgen_data would have the symbol
'race stored for stage. The method stage_race would then be called for
showing stuff to the player, and commands were passed from parse to
command_race. Here's what my main parse method looks like:

@program $pgen_parser.parse() +access=pub
  arg obj_user, str_cmd, obj_nxtparser, @lst_othrparsers;
  var sym_stage;

  str_cmd = str_cmd.trim();
  //If null command, show stage again...
  if (!str_cmd || str_cmd == "")
      .stage(obj_user);

  // Direct drop through...
  if (str_cmd && str_cmd[1] == ">")
      return obj_nxtparser.parse(obj_user, substr(str_cmd, 2),
@lst_othrparsers);

  sym_stage = tosym("command_" + (obj_user.pgen_data())['stage]);
  .(sym_stage)(obj_user, str_cmd);

  return obj_nxtparser.parse(obj_user, substr(str_cmd, 2),
@lst_othrparsers);
.

    Hope that convoluted code helps set you in the right direction. If not,
feel free to pester for further elaboration... though I won't be around to
answer till tomorrow! Many blessings upon ye all, have a safe and happy New
Year! DON'T DRIVE KASHNOOKERED, DAMNIT!!!!

- Grim



----- Original Message -----
From: "Gary Whitten" <gwhitten at attbi.comTo: "ColdStuff" <coldstuff at cold.orgSent: Tuesday, December 31, 2002 8:12 AM
Subject: [Coldstuff] Parsers


> Hi folks, it's me again.
>
> I've been digging into character creation and have gotten to the
> .add_parser($chargen_parser) line in .new_character() and have
investigated
> the parsing system.  It looks to me like the $editor_parser.parse routine
> can be used to create parsing routines which you can then use with
> add_parser and del_parser to insert dialog into sections of the code.
> However, once again, I'm having issues of accessing this.  It seems a bit
> too complex to use with an eval commandline.
>
> So, if anyone has any experience with this could you tell me if my
> assessment of this is accurate and how to use it if so?
>
> Thanks muchly.
>
> Gary
>
> P.S.  I wish all readers a Happy New Year.  Be safe.
>
> _______________________________________________
> Cold-Coldstuff mailing list
> Cold-Coldstuff at cold.org> http://web.cold.org/mailman/listinfo/cold-coldstuff



More information about the Cold-Coldstuff mailing list