[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

# Re: Hacking the parser

- Date: Mon, 30 Jun 97 13:25:10 PDT
- From:
- Cc: moo-cows@the-b.org
- In-reply-to: Your message of "30 Jun 1997 20:23:32 +0200." <y8azps8q7a3.fsf@horten.artcom.de>

    Andreas Bogk wrote:
    >
    > Is there a way to resubmit a string to the parser? Then I could write
    > a preprocessor which moves the second verb part to the front, which
    > the LambdaMOO parser can understand. Or do you have any other idea on
    > how to solve that?

    In 1.8.0 you can use #0:do_command to do that sort of rewriting.  The idea
    is:

    	if (already rewritten)
    	  return 0;
    	else
    	  argstr = rewrite(argstr);
    	  force_input(player, argstr, 1);
    	  return 1;
    	endif

    The hack I came up with for identifying a rewritten string was to insert
    the string "" at the second character in the rewrite, and test for that
    in argstr when :do_command is called again on the rewritten input.  Since
    that will fall in the verb name in the builtin parser, it will be totally
    ignored, but it gives you a way to identify your string.  So:

    	if (index(argstr, "\"\"") == 1)
    	  return 0;
    	else
    	  argstr = rewrite(argstr);
    	  argstr[2..1] = "\"\"";
    	  force_input(player, argstr, 1);
    	  return 1;
    	endif

    There may be better ways to accomplish this.

    As for your overall goal, I'd recommend that you write your own parser
    rather than try to make the existing one work for German.  German (as
    you obviously know if you're translating) imperatives just don't fit
    into the "verb dobj prop iobj" format very well.

    BTW, I'd be interested to know what system you've devised to managing
    things like naming (how do you render object names in different cases?)
    matching (how do you match objects specified in different cases?).

    --Ben

References:

- Hacking the parser

- From: Andreas Bogk <andreas@artcom.de>

- Prev by Subject: Hacking the parser
- Next by Subject: re:hash & balanced trees
- Prev by thread: Hacking the parser
- Next by thread: JHM Core Availability?
- Index(es):
  - Subject
  - Thread

Home | Subject Index | Thread Index