2000Q1/
<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD&#45;Dev] Storing tokens with flex &#38; bison -->
<!--X-From-R13: Quevf Fheare <puevfgNeq.oop.pb.hx> -->
<!--X-Date: Sat, 01 Jan 2000 11:12:14 &#45;0800 -->
<!--X-Message-Id: Pine.GSU.4.10.10001011707210.3014&#45;100000@inet5 -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: Pine.LNX.4.10.9912310201370.2677&#45;100000#azura,swipnet.se -->
<!--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:christ#rd,bbc.co.uk">
</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="msg00004.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00006.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Thread:&nbsp;
[&nbsp;<a href="msg00002.html">Previous</a>
&nbsp;|&nbsp;<a href="msg00010.html">Next</a>
&nbsp;]
&nbsp;&nbsp;&nbsp;&nbsp;
Index:&nbsp;
[&nbsp;<A HREF="author.html#00005">Author</A>
&nbsp;|&nbsp;<A HREF="#00005">Date</A>
&nbsp;|&nbsp;<A HREF="thread.html#00005">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>: Chris Turner &lt;<A HREF="mailto:christ#rd,bbc.co.uk">christ#rd,bbc.co.uk</A>&gt;</LI>
<LI><em>Date</em>: Sat, 1 Jan 2000 17:47:58 +0000 (GMT)</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 Fri, 31 Dec 1999, Christer Enfors wrote:

&gt; I'm not sure if this is the proper forum for this kind of question, but I
&gt; can't find any mailing lists for lex &amp; yacc, and it is a MUD I'm
&gt; developing...
&gt; 
&gt; I want to write a MUD server, and for this I want to develop a LPC-like
&gt; interpreting programming (or call it scripting if you like) language with
&gt; flex and bison.
&gt; 
&gt; When flex reads a file, would it be a good idea to store the tokens
&gt; returned from yylex() in a list? I was thinking one list for each function
&gt; definition, and then having bison read from that list when executing that
&gt; function, instead of reading directly from the file using flex?
&gt; 
&gt; If so, how would I get yylex() to return tokens from my list instead of
&gt; tokens from the file? Or would that be going about it the wrong way?

To get yylex() to return the tokens from the list, you'd have replace the
input routine it uses, with one that fakes input based upon the list of
tokens.  This is more hassle than it's worth *8).

The correct/easiest way to do it, is to get bison to call a wrapper function
that either calls yylex() or pops the next token off the list.

&gt; Or should I simply read the function definition from the file with flex
&gt; each time I want to execute the function?

Well this would always work with what you have already.  It might be a bit
slower.  If you want a real speed increase, you would be better off compiling
the function into some form of byte-code, which could be run though without
needing to parse anything.

&gt; Maybe someone could point me to a lex &amp; yacc tutorial that includes
&gt; writing an interpreted language that allowes user defined functions
&gt; written in that language, since that is basically what I'm trying to do
&gt; myself.

The O'Reilly Lex &amp; Yacc book is well written and contains many tutorials.

Chris
-- 
christ#rd,bbc.co.uk   #include &lt;stddisclaimer.h&gt;   <A  HREF="http://www.fysh.org/~maddy">http://www.fysh.org/~maddy</A>

   "So this is really me? A no-style gimbo with teeth druids could use as a
       place of worship" - Duaine Dibley (Red Dwarf - "Back to Reality")




_______________________________________________
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>
<ul compact><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><A NAME="00010" HREF="msg00010.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></strong>
<ul compact><li><em>From:</em> Christer Enfors &lt;enfors#swipnet,se&gt;</li></ul>
</UL></LI></UL>
<!--X-Follow-Ups-End-->
<!--X-References-->
<UL><LI><STRONG>References</STRONG>:
<UL>
<LI><STRONG><A NAME="00000" HREF="msg00000.html">[MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
<UL><LI><EM>From:</EM> Christer Enfors &lt;enfors#swipnet,se&gt;</LI></UL></LI>
</UL></LI></UL>
<!--X-References-End-->
<!--X-BotPNI-->
<UL>
<LI>Prev by Date:
<STRONG><A HREF="msg00004.html">Re: [MUD-Dev] Embedded languages, object persistance... ack.</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00006.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00002.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00010.html">Re: [MUD-Dev] Storing tokens with flex &amp; bison</A></STRONG>
</LI>
<LI>Index(es):
<UL>
<LI><A HREF="index.html#00005"><STRONG>Date</STRONG></A></LI>
<LI><A HREF="thread.html#00005"><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>
<ul compact>
<ul compact>
<LI><strong><A NAME="00041" HREF="msg00041.html">Re: [MUD-Dev] Admins as Mortals twist</A></strong>, 
Matthew Mihaly <a href="mailto:diablo#best,com">diablo#best,com</a>, Mon 03 Jan 2000, 19:02 GMT
</LI>
</ul>
</ul>
<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
</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>