[MUD-Dev] Parser engines
Brian Hook
hook_l at bookofhook.com
Fri Apr 2 20:33:38 CEST 2004
FWIW, I revamped things considerably once I realized I was hitting a
limit by trying to decompose ALL sentences into V NP [[PP] NP].
Several obvious examples where this fails:
> say hello everyone
You say, "Hello everyone"
> avarian, say destro mestro klagaro
Avarian says, "destro mestro klagaro"
> tell oz Dude, I think this is broken
You tell oz, "Dude, I think this is broken"
> sudo create item 9212
You create a bronze spear
With sufficient special casing it can still be handled, but I
decided that going to a system more IF-like was the best idea. Of
course, I had to figure this out the hard way by iteratively coming
up with different approaches, until I finally started defining verbs
in terms of grammars, and voila, I was back to an Inform/Hugo/TADS
grammar system.
Now my parser flow kind of works like this:
-- Get actor for sentences like "dave, shoot the orc"
actor =3D parse_actor( line )
if actor =3D=3D nil
actor =3D client
end
-- Get the verb
verb =3D parse_verb( line )
verb( actor, line )
Each verb function then calls appropriate helper routines in order
to validate the incoming syntax, grab noun phrases (with or without
constraints), resolve/disambiguate, and then dispatches accordingly.
I didn't define a separate grammar altogether a la Hugo/Inform/TADs,
but that's mostly laziness on my part.
So far it works really well. The bulk of verbs decompose into the
canonical form and thus have very similar snippets of code (which is
one reason a grammar driven version would probably be better in the
long run).
Brian
www.bookofhook.com
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev
More information about the mud-dev-archive
mailing list