msg00359.html
1999Q1/msg00359.html · 8.4 KB
From the archive 1999Q1.zip
Download the archive « Back to the archive contents
<!-- MHonArc v2.4.4 -->
<!--X-Subject: [MUD-Dev] Re: Question on c++ switch optimization, and parsers in general. -->
<!--X-From-R13: Ayvire Xbjrgg <vprphorNvuht.pb.am> -->
<!--X-Date: Mon, 8 Feb 1999 13:23:52 -0800 -->
<!--X-Message-Id: Pine.LNX.3.96.990209100518.1116A-100000#agrajag,internal -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: Pine.SGI.3.96.990208111536.930G-100000#zazu,angel.com -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, [MUD-Dev] Re: Question on c++ switch optimization, and parsers</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:icecube#ihug,co.nz">
</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="msg00358.html">Previous</a>
| <a href="msg00360.html">Next</a>
]
Thread:
[ <a href="msg00358.html">Previous</a>
| <a href="msg00360.html">Next</a>
]
Index:
[ <A HREF="author.html#00359">Author</A>
| <A HREF="#00359">Date</A>
| <A HREF="thread.html#00359">Thread</A>
]
<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</H1>
<HR>
<!--X-Subject-Header-End-->
<!--X-Head-of-Message-->
<UL>
<LI><em>To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Subject</em>: [MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</LI>
<LI><em>From</em>: Oliver Jowett <<A HREF="mailto:icecube#ihug,co.nz">icecube#ihug,co.nz</A>></LI>
<LI><em>Date</em>: Tue, 9 Feb 1999 10:23:34 +1300 (NZDT)</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
</UL>
<!--X-Head-of-Message-End-->
<!--X-Head-Body-Sep-Begin-->
<HR>
<!--X-Head-Body-Sep-End-->
<!--X-Body-of-Message-->
<PRE>
On Mon, 8 Feb 1999, Adam Wiggins wrote:
> I've always been fond of the simplicity of the "big array with everything
> you need to know about a given command" method. Apparently some folks in
> the diku world are as well: I know that stock CircleMUD handles commands
> this way.
The problem with this is when you have a lot of command-specific
information embedded in the command. For example the parser I'm
currently working on defines the "name" command, used to give a name to
another player or NPC, as:
{ "name", "<charroom> *here [*as] <string>", true, new_do_name_char },
{ NULL, "(<player>|<charroom>) [*as] <string>", true, new_do_name_char },
{ NULL, "<word> <string>", false, fail_string, "You see no %s here.\n" },
{ NULL, "[<string>]", false, fail_string, "Name whom as what?\n" },
Currently this is in a table with several other commands. It would be
nice, however, to have this information actually kept with the command
itself.
I'm thinking of using ELF sections for this: something like (no guarantees
if this even compiles)
#define ADD_COMMAND(x) static command_data * x ## _ptr \
__attribute__((section("commands"))) = &x
command_data name_command[] = { /* command details here */ }
ADD_COMMAND(name_command);
Then the main parser can run through the "commands" section, following the
pointers to get a list of all the commands:
/* Defined by the linker, maybe - solaris doesn't IIRC, you have to
position these symbols in the right section in .o's linked at the start
and end of your link line
*/
extern command_data *__start_cvs, *__stop_cvs;
command_data **p;
for (p = &__start_cvs; p < &__stop_cvs; p++) {
/* do something with (**p) */
}
ELF sections are quite useful for gathering data together like this -
I've also used them to gather CVS IDs from source files at runtime.
-O
</PRE>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<ul compact><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><A NAME="00360" HREF="msg00360.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>
<ul compact><li><em>From:</em> Oliver Jowett <icecube#ihug,co.nz></li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00357" HREF="msg00357.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
<UL><LI><EM>From:</EM> Adam Wiggins <adam#angel,com></LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00358.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00360.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00358.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00360.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00359"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00359"><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>[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00356" HREF="msg00356.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Ola Fosheim Grøstad <a href="mailto:olag#ifi,uio.no">olag#ifi,uio.no</a>, Mon 08 Feb 1999, 16:53 GMT
<UL>
<LI><strong><A NAME="00365" HREF="msg00365.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Ben Greear <a href="mailto:greear#cyberhighway,net">greear#cyberhighway,net</a>, Tue 09 Feb 1999, 02:54 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00357" HREF="msg00357.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Adam Wiggins <a href="mailto:adam#angel,com">adam#angel,com</a>, Mon 08 Feb 1999, 19:47 GMT
<UL>
<LI><strong><A NAME="00358" HREF="msg00358.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Mark Gritter <a href="mailto:mark#erdos,Stanford.EDU">mark#erdos,Stanford.EDU</a>, Mon 08 Feb 1999, 21:18 GMT
</LI>
<LI><strong><A NAME="00359" HREF="msg00359.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Oliver Jowett <a href="mailto:icecube#ihug,co.nz">icecube#ihug,co.nz</a>, Mon 08 Feb 1999, 21:23 GMT
<UL>
<LI><strong><A NAME="00360" HREF="msg00360.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Oliver Jowett <a href="mailto:icecube#ihug,co.nz">icecube#ihug,co.nz</a>, Mon 08 Feb 1999, 21:30 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
<LI><strong><A NAME="00361" HREF="msg00361.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Ola Fosheim Grøstad <a href="mailto:olag#ifi,uio.no">olag#ifi,uio.no</a>, Tue 09 Feb 1999, 00:16 GMT
</LI>
<LI><strong><A NAME="00362" HREF="msg00362.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Richard Woolcock <a href="mailto:KaVir#dial,pipex.com">KaVir#dial,pipex.com</a>, Tue 09 Feb 1999, 01:12 GMT
<UL>
<LI><strong><A NAME="00363" HREF="msg00363.html">[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.</A></strong>,
Marc Hernandez <a href="mailto:marc#ias,jb.com">marc#ias,jb.com</a>, Tue 09 Feb 1999, 02:35 GMT
</LI>
</UL>
</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>