MOO-cows Mailing List Archive

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

Re: Hacking the parser

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

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

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;
	  argstr = rewrite(argstr);
	  argstr[2..1] = "\"\"";
	  force_input(player, argstr, 1);
	  return 1;

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?).


Home | Subject Index | Thread Index