copying an I6 array (for a tweak to Ron's Original Parser)

For a parser tweak that I’m working on, I’d like to be able to cache the match list, run NounDomain again to see what pattern union it returns, and then restore the original match list.

I’m using Ron Newcomb’s I7 implementation of the parser, but it seems as though the match list is not itself an I7 list, but three I6 arrays and four globals that are accessed through I7 phrase calls. As in the below code:

[spoiler][code]Include (-
Array match_list --> MATCH_LIST_WORDS; ! An array of matched objects so far
Array match_classes --> MATCH_LIST_WORDS; ! An array of equivalence classes for them
Array match_scores --> MATCH_LIST_WORDS; ! An array of match scores for them
Global number_matched; ! How many items in it? (0 means none)
Global number_of_classes; ! How many equivalence classes?
Global match_length; ! How many words long are these matches?
Global match_from; ! At what word of the input do they begin?
-).

To decide which 0-based index based rulebook producing an object is the match list: (-match_list-).
To decide which 0-based index based rulebook producing a number is the match list’s groups: (-match_classes-).
To decide which 0-based index based rulebook producing a number is the match score list: (-match_scores-).
The number of objects in the match list is a number that varies.
The number of match groups is a number that varies.
The number of words matched per object is a number that varies.
The next word to parse’s position is a number that varies.

The number of objects in the match list variable translates into I6 as “number_matched”.
The number of match groups variable translates into I6 as “number_of_classes”.
The number of words matched per object variable translates into I6 as “match_length”.
The next word to parse’s position variable translates into I6 as “match_from”.
[/code][/spoiler]

So to cache and restore the match list, I’ll have to copy these over to other arrays and globals. Is there a single-command way to copy arrays in I6, or will I have to write a loop to do it?

In case you’re wondering about the use case:

[spoiler]I’m trying to modify the behavior of the disambiguation prompt. At the disambiguation prompt, the standard I7 parser checks to see if the first word typed was a verb. If it is, it abandons the disambiguation and starts a new command; if not, it sticks the stuff that was typed into the old command and tries to reparse it. If one of the disambiguation choices has a verb in its name, this means Inform won’t understand it because it’ll interpret the verb as indicating a new command; and if the player tries to abandon disambiguation with a verbless command like “north” then Inform will think it’s trying to disambiguate.

I’d like to be able to run a modified version of NounDomain on the text typed in at the disambiguation prompt to see if it’s a noun in scope. If it is, then we put the text back into the original command and reparse (as in the normal disambiguation response); if it isn’t, then we have a hook for printing an apologetic message (“Since I couldn’t understand that as an answer to the question, I’ll try it as a new command”) and we parse the command anew. This also might provide some friendlier error messages.

–though now that I think of it, I may not need to retain the old match list, since either way we wind up reparsing. Where retaining the old match list would be really useful is that it might allow us to compare the new match list with the old match list, see if they have anything in common, and reparse as a new command if they don’t (possibly with a message saying “That wasn’t one of the choices”). Hmm. I’ll try this when I have time. But if you’ve got this far, the answer to the question about I6 arrays would still be useful![/spoiler]

There is no single-command array copy in i6. You’ll note that the I6 parser code contains lots of little loops.

Thanks!

This gives me an extra incentive to try the way I was talking about in the second spoiler, I guess. (Though it would be good for me to learn how to make an I6 loop too.)

There are opcodes to copy blocks of memory, but you probably don’t want to use them.

No, that sounds scary! Thanks, though.