I’m trying to clean off my rusty Dialog skills again, and one of its big advantages over Inform is how flexible and user-customizable the parser is. So I’m currently trying to adapt it to parse a head-final language.
What’s a head-final language? Well, linguistically speaking, sentences are formed by taking a “head” and attaching things to it to make a phrase. For the sorts of commands we use in parser games (“verb phrases”), the head is the verb. And in English, the head of a phrase tends to come at the beginning. Prepositions come before nouns, verbs come before objects, and so on.
Pedantry
Or at least this is one popular model of how syntax works. There are others too. But this one’s useful for my purposes right now.
But some other languages, like Japanese, are “head-final”: the head tends to come after its arguments. Prepositions come after their nouns (making them “postpositions” instead), and verbs come after their objects. For the purposes of this discussion, let’s imagine a version of English where we use commands like LOOK, TROLL X, COIN TAKE, COIN TROLL GIVE.
This doesn’t really work in Inform, where the parser starts by looking at the first word of the command to figure out which grammar to use. But in Dialog, it might! So I’m trying to figure out how best to do that. (I think there was some discussion of Dialog for Japanese years ago but I can’t find it again now…)
Option one, rewrite the command. Once you’ve got a sentence, take the last word and put it at the beginning instead. Now most of the machinery can work the same way as English.
Option two, adjust the parser. Make it start by looking at the last word and proceed from there.
The latter seems like it would be a more interesting Dialog exercise, exploring the flexibility of the parser, but Dialog is built around CONS-style lists, where the first element is the easiest to access. Will I be sacrificing tons of efficiency if I try to run through lists in reverse order?