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 what?
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".

  • 3
    Sort of answer can be found here:softwareengineering.stackexchange.com/questions/218774/… A c# port is claimed to be here:github.com/zhoranet/Inglish
    – UncleBod
    Nov 15, 2018 at 14:21
  • 1
    Not the Hobbit, so strictly not an answer, but Infocom parsers did something similar, and high-level explanations are easy to find, e.g. here or here, and the source of e.g. Zork is available.
    – dirkt
    Nov 15, 2018 at 14:26
  • 3
    Wilderland is a nice tool to explore The Hobbit and its internals (in particular the object database). Nov 15, 2018 at 14:28
  • 3
    @John, what's the problem exactly? You told the computer to kill lunch with Elrond. I would be confused as well but, in the end, it managed to kill lunch. That shows real adaptability :-)
    – user6464
    Nov 16, 2018 at 0:33
  • 2
    @paxdiablo: that lunch must have had really raw meat.
    – ninjalj
    Nov 18, 2018 at 0:43

1 Answer 1


"Open all" is simple action and target syntax searchable through keywords given the current context (e.g. room player is in). ALL here means that machine will look though all "openable" object, and will report back (or will take only first one it finds).

ask Gandalf about the curious map then take sword and kill troll with it

This one is also easily parseable, as has same structure as action + target (ask Gendalf, take sword, kill troll), having object for specific action (about, with) and object (curios map, "it"=sword), separators and order keywords ("and" and "then").

How did this parser work, to allow it to be so small, and yet understand such intricate syntax?

Syntax is not intricate. It is subject to logic and easy syntax parsing.

How it works... ask developers who designed algorithm for it, or perform disassembly.

To see how complex parser is, try different syntax, for example the following:

ask Gandalf curious map and take sword and kill troll


curious map Gandalf ask and sword take and troll kill

and see the results. Most probably parser knows words "and" and "then", and all others are just a combinations of allowed keywords corresposind to allowed actions in the specific context, thus their order may not matter and "the", "with" and "about" are discarded.

Feeding various data in and looking at result is the only way for finding out how black box actually works.

  • 4
    "Syntax is not intricate": I'd have to disagree. For example, how did you determine that "it" refers to the sword, especially if you randomly ignore the word "with"? Nov 15, 2018 at 16:02
  • 1
    @Wilson you don't. If the player is carrying something that kills trolls, you get a dead troll. If not, you get a dead player. Everything else is an artefact of the player's "CPU", not the computer's.
    – alephzero
    Nov 15, 2018 at 16:05
  • 10
    @alephzero I think part of the issue here is that you’re answering with generalities, while the question asks specifically about the parser used in The Hobbit. Since the context is defined, there’s not much room for “most probably” etc. This particular parser is notoriously complex (see its disassembly), I suspect (but don’t know, which is why this is a comment rather than an answer) that it does more than look for a few simple keywords. Nov 15, 2018 at 16:14
  • 3
    This isn't a good answer to the question; it's far too generic. We've already got a rather generic "English-like parser" question (if I can find it...); this is specifically about one game.
    – wizzwizz4
    Nov 15, 2018 at 17:01
  • 8
    @Anonymous - "without 100% knowledge of how it works it is impossible to satisfy the answer" ... and yet, the program is available to the public, and has been for 36 years, is considered an iconic example of its genre, and such an analysis is possible for any sufficiently skilled person with motivation to do so. It seems unlikely that nobody knows.
    – Jules
    Nov 16, 2018 at 1:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .