Most adventure games, to keep the parser simple, might just have some simple rules, which accepts verb + noun or a cardinal direction, and simple things like that. That's almost a CFG, so in Backus-Naur Form, a simple parser might look like:
s => D
s => VERB
s => VERB object
object => NOUN
object => ADJ NOUN
ADJ => {red, big, sharp, wooden}
NOUN => {stick, sword, mailbox, goon}
VERB => {take, fight, open, ...}
D => {north, east, south, west}
Empirically, this is the kind of parser that many adventure games had in them, to accept simple sentences like open mailbox or north or take wooden sword or exit. That works well enough, and doesn't take much more memory than the list of words. It's essentially the same grammar as a very primitive computer language like an assembler, just with English words.
Now when the Hobbit came out, for the ZX Spectrum (it needed the 48K version), it had a much more advanced parser, allowing it to accept sentences in an impressive subset of English which they called Inglish, like "ask Gandalf about the curious map then take sword and kill troll with it. That's some tricky pronoun resolution right there (did you mean to kill the troll with the sword, or the mapinstrumental? Or even with Gandalf or the trollcomitative?
Also, if you don't give the object, the dialogue might go something like this:
> OPEN
Open what?
> ALL
You open the green door. You open the chest and a bat flies out. Gandalf closes the chest.
... which means that context is stored in between each entry (in order that the game knows what to do to all), and it also means that there is a one-to-many mapping between pronoun and object.
I'm impressed that this all fits into 48K, which also houses input-output routines (for some reason the game didn't use the ones in ROM), plenty of graphics, all characters, objects and prose, etc.
How did this parser work, to allow it to be so small, and yet understand such intricate syntax?
1 Instrumental means "using the thing to accomplish the task" 2 Comitative means "accomplishing the task together with someone". It's an ambiguity in the English word "with".
s => vbes => VERB? – JeremyP Nov 15 '18 at 16:23