2000Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev] Storing tokens with flex &#38; bison -->
<!--X-From-R13: Quevfgre Sasbef <rasbefNfjvcarg.fr> -->
<!--X-Date: Sat, 01 Jan 2000 12:04:17 &#45;0800 -->
<!--X-Message-Id: Pine.LNX.4.10.10001012054260.7521&#45;100000#azura,swipnet.se -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: Pine.GSU.4.10.10001011707210.3014&#45;100000@inet5 -->
<!--X-Head-End-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>MUD-Dev message, Re: [MUD-Dev] Storing tokens with flex &amp; bison</title>
<!-- meta name="robots" content="noindex,nofollow" -->
<link rev="made" href="mailto:enfors#swipnet,se">
</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>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
<br clear=all><hr>
<!--X-Body-Begin-->
<!--X-User-Header-->
<!--X-User-Header-End-->
<!--X-TopPNI-->

Date:&nbsp;
[&nbsp;<a href="msg00009.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00011.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00005.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00006.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00010">Author</A>
&nbsp;|&nbsp;<A HREF="#00010">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00010">Thread</A>
&nbsp;]

<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev] Storing tokens with flex &amp; bison</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>: Re: [MUD-Dev] Storing tokens with flex &amp; bison</LI>
<LI><em>From</em>: Christer Enfors &lt;<A HREF="mailto:enfors#swipnet,se">enfors#swipnet,se</A>&gt;</LI>
<LI><em>Date</em>: Sat, 1 Jan 2000 20:58:17 +0100 (CET)</LI>
<LI><em>Reply-To</em>: <A HREF="mailto:mud-dev#kanga,nu">mud-dev#kanga,nu</A></LI>
<LI><em>Sender</em>: <A HREF="mailto:mud-dev-admin#kanga,nu">mud-dev-admin#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 Sat, 1 Jan 2000, Chris Turner wrote:

&gt; On Fri, 31 Dec 1999, Christer Enfors wrote:
&gt; 
&gt; &gt; I'm not sure if this is the proper forum for this kind of question, but I
&gt; &gt; can't find any mailing lists for lex &amp; yacc, and it is a MUD I'm
&gt; &gt; developing...
&gt; &gt; 
&gt; &gt; I want to write a MUD server, and for this I want to develop a LPC-like
&gt; &gt; interpreting programming (or call it scripting if you like) language with
&gt; &gt; flex and bison.
&gt; &gt; 
&gt; &gt; When flex reads a file, would it be a good idea to store the tokens
&gt; &gt; returned from yylex() in a list? I was thinking one list for each function
&gt; &gt; definition, and then having bison read from that list when executing that
&gt; &gt; function, instead of reading directly from the file using flex?
&gt; &gt; 
&gt; &gt; If so, how would I get yylex() to return tokens from my list instead of
&gt; &gt; tokens from the file? Or would that be going about it the wrong way?
&gt; 
&gt; To get yylex() to return the tokens from the list, you'd have replace the
&gt; input routine it uses, with one that fakes input based upon the list of
&gt; tokens.  This is more hassle than it's worth *8).
&gt; 
&gt; The correct/easiest way to do it, is to get bison to call a wrapper function
&gt; that either calls yylex() or pops the next token off the list.

That's what I meant, I guess. I just didn't know you could get bison to
call a different function instead of yylex(). I'll check the man page,
thanks.

&gt; &gt; Or should I simply read the function definition from the file with flex
&gt; &gt; each time I want to execute the function?
&gt; 
&gt; Well this would always work with what you have already.  It might be a bit
&gt; slower.  If you want a real speed increase, you would be better off compiling
&gt; the function into some form of byte-code, which could be run though without
&gt; needing to parse anything.

I thought my supposed stored linked list of tokens was considered
"byte-code", but I guess it's not that simple. Looks like I better hit the
Dragon book some more, I bet this sort of stuff is explained in there
somewhere.

&gt; &gt; Maybe someone could point me to a lex &amp; yacc tutorial that includes
&gt; &gt; writing an interpreted language that allowes user defined functions
&gt; &gt; written in that language, since that is basically what I'm trying to do
&gt; &gt; myself.
&gt; 
&gt; The O'Reilly Lex &amp; Yacc book is well written and contains many tutorials.

Right, but it doesn't have a tutorial that involves storing the source
code in any format for later execution, which is what I'm looking for in
this case.

--
	             -=-=- Christer Enfors -=-=-

       "I do my music in pure machine code using an assembler."
			    - Rob Hubbard




_______________________________________________
MUD-Dev maillist  -  MUD-Dev#kanga,nu
<A  HREF="http://www.kanga.nu/lists/listinfo/mud-dev">http://www.kanga.nu/lists/listinfo/mud-dev</A>

</PRE>

<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<HR>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00005" HREF="msg00005.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
<UL><LI><EM>From:</EM> Chris Turner &lt;christ#rd,bbc.co.uk&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00009.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00011.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00005.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00006.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00010"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00010"><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-Dev] Admins as Mortals twist</STRONG>, <EM>(continued)</EM>
<ul compact>
<LI><strong><A NAME="00003" HREF="msg00003.html">Re: [MUD-Dev] Admins as Mortals twist</A></strong>, 
Philip Loguinov -- Draymoor <a href="mailto:fibhufky#erols,com">fibhufky#erols,com</a>, Sat 01 Jan 2000, 05:42 GMT
</LI>
</ul>
</LI>
<LI><strong><A NAME="00000" HREF="msg00000.html">[MUD-Dev] Storing tokens with flex &amp; bison</A></strong>, 
Christer Enfors <a href="mailto:enfors#swipnet,se">enfors#swipnet,se</a>, Fri 31 Dec 1999, 21:22 GMT
<UL>
<LI><strong><A NAME="00002" HREF="msg00002.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></strong>, 
Rahul Sinha <a href="mailto:rsinha#glue,umd.edu">rsinha#glue,umd.edu</a>, Fri 31 Dec 1999, 23:12 GMT
</LI>
<LI><strong><A NAME="00005" HREF="msg00005.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></strong>, 
Chris Turner <a href="mailto:christ#rd,bbc.co.uk">christ#rd,bbc.co.uk</a>, Sat 01 Jan 2000, 19:12 GMT
<UL>
<LI><strong><A NAME="00010" HREF="msg00010.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></strong>, 
Christer Enfors <a href="mailto:enfors#swipnet,se">enfors#swipnet,se</a>, Sat 01 Jan 2000, 20:04 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00006" HREF="msg00006.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></strong>, 
Per Vognsen <a href="mailto:vognsen#mindless,com">vognsen#mindless,com</a>, Sat 01 Jan 2000, 19:12 GMT
<UL>
<LI><strong><A NAME="00009" HREF="msg00009.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></strong>, 
Christer Enfors <a href="mailto:enfors#swipnet,se">enfors#swipnet,se</a>, Sat 01 Jan 2000, 19:54 GMT
</LI>
</UL>
</LI>
<LI><strong><A NAME="00007" HREF="msg00007.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></strong>, 
J C Lawrence <a href="mailto:claw#kanga,nu">claw#kanga,nu</a>, Sat 01 Jan 2000, 19:29 GMT
<UL>
<LI><strong><A NAME="00011" HREF="msg00011.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></strong>, 
Christer Enfors <a href="mailto:enfors#swipnet,se">enfors#swipnet,se</a>, Sat 01 Jan 2000, 20:04 GMT
</LI>
</UL>
</LI>
</UL>
</LI>
</UL></BLOCKQUOTE>

</ul>
<hr>
<center>
[&nbsp;<a href="../">Other Periods</a>
&nbsp;|&nbsp;<a href="../../">Other mailing lists</a>
&nbsp;|&nbsp;<a href="/search.php3">Search</a>
&nbsp;]
</center>
<hr>
</body>
</html>