<!-- MHonArc v2.4.4 --> <!--X-Subject: Re: mud grammar (was Re: Just a bit of musing) --> <!--X-From-R13: ptNnzv-pt.UenlEntr.Sqzbagba.OP.QO (Quevf Uenl) --> <!--X-Date: from babe.globecomm.net [207.51.48.8] by mx01.ny.us.ibm.net id 858057643.118440-1 Tue Mar 11 05:20:43 1997 --> <!--X-Message-Id: 9703110437.7v1z@ami-cg.GraySage.Edmonton.AB.CA --> <!--X-Content-Type: text/plain --> <!--X-Head-End--> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>MUD-Dev message, Re: mud grammar (was Re: Just a bit of musing)</title> <!-- meta name="robots" content="noindex,nofollow" --> <link rev="made" href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA"> </head> <body background="/backgrounds/paperback.gif" bgcolor="#ffffff" text="#000000" link="#0000FF" alink="#FF0000" vlink="#006000"> <font size="+4" color="#804040"> <strong><em>MUD-Dev<br>mailing list archive</em></strong> </font> <br> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] <br clear=all><hr> <!--X-Body-Begin--> <!--X-User-Header--> <!--X-User-Header-End--> <!--X-TopPNI--> Date: [ <a href="msg00084.html">Previous</a> | <a href="msg00086.html">Next</a> ] Thread: [ <a href="msg00083.html">Previous</a> | <a href="msg00112.html">Next</a> ] Index: [ <A HREF="author.html#00085">Author</A> | <A HREF="#00085">Date</A> | <A HREF="thread.html#00085">Thread</A> ] <!--X-TopPNI-End--> <!--X-MsgBody--> <!--X-Subject-Header-Begin--> <H1>Re: mud grammar (was Re: Just a bit of musing)</H1> <HR> <!--X-Subject-Header-End--> <!--X-Head-of-Message--> <UL> <LI><em>To</em>: <A HREF="mailto:mud-dev#null,net">mud-dev#null,net</A></LI> <LI><em>Subject</em>: Re: mud grammar (was Re: Just a bit of musing)</LI> <LI><em>From</em>: <A HREF="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</A> (Chris Gray)</LI> <LI><em>Date</em>: Mon, 10 Mar 97 21:37:46 MST</LI> </UL> <!--X-Head-of-Message-End--> <!--X-Head-Body-Sep-Begin--> <HR> <!--X-Head-Body-Sep-End--> <!--X-Body-of-Message--> <PRE> :I think we have a misunderstanding here. There's grammar (the structure of :a language) and then there's vocabulary (all of the individual words that :make up the language). I agree that the vocabulary is dynamic. I don't :think the grammar is. Well, mine is. It was one of the first things that I needed. In the mail room, there are added commands which are used to send email to people outside the MUD and read your email. In the newsroom there are added commands which allow you to read and post news on the local machine, which, if the machine has a regular newsfeed like mine, will actually go out over the internet. I *didn't* want such commands available everywhere on the MUD! If I remember, I'll send some email out from there the next time I have it up for that kind of testing (I'm doing client fiddling at the moment). [I won't quote much of Carter's material, but will just make a rambling reply.] Another example is the way my online building commands work. The system has a verb-type called "VerbTail", where everything in the command after the verb is just passed to the verb as a string. I use that with verb @/build/construct/b, so that that command can then parse the remaining input according to another, completely different, grammar. In fact, if the first word of *that* tail is object/o or room/r, then yet more grammars are invoked on further tails. So: build room new north indoors in the Solarium invokes the 'build' verb. It sees the rest of the input and passes it to the build grammar. The verb is then 'room'. It takes the rest of the input and passes it to the room-building grammar. The room building grammar has a verb 'new' which requires a direction, a room-type and a room-name, all of which are handled as "rest-of-input" processing. It's kinda tough to do this with yacc! (Well, maybe not, but doing it this way keeps all mention of the verbs/etc. for building out of the main grammar - modularity in all things!) How about simple things like "whisper" or "say"? Sure, we all have " or something as a special-cased shortcut for "say", but what about whisper, where you are whispering *to* someone in particular: whisper to Fred Let's attack Sam! Doesn't fit in a yacc grammar very well. I also have a 'with' verb, although I don't currently have any real uses for it in the current scenario. It takes an object, identifies it in your inventory/location, and then looks for a grammar attached to that object to parse the rest of the input with. I intend it for powerful magical objects, eg: "with staff zap the frog". Right now, I have a 'cast' verb for wizards. It takes the next word in the input, and looks it up as a procedure in the player's "spell table", which is just another table of whatever's that can be attached to the player or other things. If it finds a procedure by that name, it invokes it, and that procedure has access to the rest of the input command. So, I can do "cast heal Fred", or "cast teleport Fred here", etc. Sure, you can put this in some main, overall grammar, but with this technique, wizards, who can write new code in the running system, can easily add new spell commands to their own spell tables. :An example of where this works very nicely is with magic. Identify the verb :"cast" as special in your lexical analyzer. Rather than :<verb> <object> <object> :it becomes :<verb> <spell> <object> : :Now the question, why bother? :Well, first off, it can make the mud more user-friendly. Rather than simply :reporting "huh?" on bad commands, a true parser should be able to: : 1) report the exact location of the error in the command : 2) offer up suggestions (tab completion of commands) Well, in my 'build' example above, if you enter "build twiddle", the build command can't find the verb 'twiddle' in the build grammar, so it reports "Unknown build command 'twiddle'." Similar for "build room twiddle". :Now, we could do all of this without learning lex/yacc, but doing it in :lex/yacc gives you a standard interface.. not to mention someone else has :written most of the ugly code for you already. Btw, the newer flavors of :the GNU lexer/parser software (glex and bison I think) offer up a C++ :version that encapsulates the parser as an object. Nifty side effect is :that you can have more than one. So, if you really want to screw with the :user's minds you could conceivably have different command sets in different :parts of your world. (something along Zelazny's Amber... the physics are :different in the place you've warped to so the commands, spells, etc are :different). Wait, it gets better... if we want to link up muds, there are :ways that one mud could export its parser object to another so, if you :wanted, you could process commands for a user in the remote mud locally :(not sure why you'd want to, but hey.... explore the possibiliteis :) Well, my grammars are already database objects that I can retrieve from wherever I want. I currently don't do what you are saying (other than the bit mentioned above), however. Another issue: do you even want to lexically scan all input the same? By making it context sensitive, you have some greater flexibility. I guess my viewpoint on this is a little different than most. I've written, er, six compilers, and never once used either lex or yacc, or any other compiler tools! I think I did the lexer/parser for my AmigaMUD in-MUD language in about a week. It has a pretty standard Algol-68 style syntax, with 'if', 'while', 'for', 'case', full functions, some special MUD operators, etc. Ack! Enough blithering - sorry - I do run on at times. -- Chris Gray cg#ami-cg,GraySage.Edmonton.AB.CA </PRE> <!--X-Body-of-Message-End--> <!--X-MsgBody-End--> <!--X-Follow-Ups--> <HR> <!--X-Follow-Ups-End--> <!--X-References--> <!--X-References-End--> <!--X-BotPNI--> <UL> <LI>Prev by Date: <STRONG><A HREF="msg00084.html">Re: Threads, IO handling, and Event Queues</A></STRONG> </LI> <LI>Next by Date: <STRONG><A HREF="msg00086.html">Re: Just a bit of musing</A></STRONG> </LI> <LI>Prev by thread: <STRONG><A HREF="msg00083.html">Re: mud grammar (was Re: Just a bit of musing)</A></STRONG> </LI> <LI>Next by thread: <STRONG><A HREF="msg00112.html">mud grammar (was Re: Just a bit of musing)</A></STRONG> </LI> <LI>Index(es): <UL> <LI><A HREF="index.html#00085"><STRONG>Date</STRONG></A></LI> <LI><A HREF="thread.html#00085"><STRONG>Thread</STRONG></A></LI> </UL> </LI> </UL> <!--X-BotPNI-End--> <!--X-User-Footer--> <!--X-User-Footer-End--> <ul><li>Thread context: <BLOCKQUOTE><UL> <LI><STRONG>Re: mud grammar</STRONG>, <EM>(continued)</EM> <ul compact> <LI><strong><A NAME="00198" HREF="msg00198.html">Re: mud grammar</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Mon 24 Mar 1997, 15:00 GMT </LI> <LI><strong><A NAME="00239" HREF="msg00239.html">Re: mud grammar</A></strong>, claw <a href="mailto:claw#null,net">claw#null,net</a>, Fri 28 Mar 1997, 04:05 GMT </LI> </ul> </LI> <LI><strong><A NAME="00081" HREF="msg00081.html">mud grammar (was Re: Just a bit of musing)</A></strong>, Carter T Shock <a href="mailto:ctso#umiacs,umd.edu">ctso#umiacs,umd.edu</a>, Mon 10 Mar 1997, 21:49 GMT <UL> <li><Possible follow-up(s)><br> <LI><strong><A NAME="00083" HREF="msg00083.html">Re: mud grammar (was Re: Just a bit of musing)</A></strong>, Nathan Yospe <a href="mailto:yospe#hawaii,edu">yospe#hawaii,edu</a>, Tue 11 Mar 1997, 02:58 GMT </LI> <LI><strong><A NAME="00085" HREF="msg00085.html">Re: mud grammar (was Re: Just a bit of musing)</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Tue 11 Mar 1997, 13:20 GMT </LI> <LI><strong><A NAME="00112" HREF="msg00112.html">mud grammar (was Re: Just a bit of musing)</A></strong>, claw <a href="mailto:claw#null,net">claw#null,net</a>, Sat 15 Mar 1997, 07:29 GMT </LI> <LI><strong><A NAME="00121" HREF="msg00121.html">Re: mud grammar (was Re: Just a bit of musing)</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Sun 16 Mar 1997, 04:15 GMT </LI> <LI><strong><A NAME="00133" HREF="msg00133.html">Re: mud grammar (was Re: Just a bit of musing)</A></strong>, claw <a href="mailto:claw#null,net">claw#null,net</a>, Tue 18 Mar 1997, 02:30 GMT </LI> <LI><strong><A NAME="00135" HREF="msg00135.html">Re: mud grammar (was Re: Just a bit of musing)</A></strong>, Chris Gray <a href="mailto:cg#ami-cg,GraySage.Edmonton.AB.CA">cg#ami-cg,GraySage.Edmonton.AB.CA</a>, Tue 18 Mar 1997, 23:50 GMT </LI> </UL> </LI> </UL></BLOCKQUOTE> </ul> <hr> <center> [ <a href="../">Other Periods</a> | <a href="../../">Other mailing lists</a> | <a href="/search.php3">Search</a> ] </center> <hr> </body> </html>