<!-- MHonArc v2.4.4 -->
<!--X-Subject: Re: [MUD-Dev] Storing tokens with flex & bison -->
<!--X-From-R13: Quevfgre Sasbef <rasbefNfjvcarg.fr> -->
<!--X-Date: Sat, 01 Jan 2000 12:04:17 -0800 -->
<!--X-Message-Id: Pine.LNX.4.10.10001012054260.7521-100000#azura,swipnet.se -->
<!--X-Content-Type: text/plain -->
<!--X-Reference: Pine.GSU.4.10.10001011707210.3014-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 & 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>
[ <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="msg00009.html">Previous</a>
| <a href="msg00011.html">Next</a>
]
Thread:
[ <a href="msg00005.html">Previous</a>
| <a href="msg00006.html">Next</a>
]
Index:
[ <A HREF="author.html#00010">Author</A>
| <A HREF="#00010">Date</A>
| <A HREF="thread.html#00010">Thread</A>
]
<!--X-TopPNI-End-->
<!--X-MsgBody-->
<!--X-Subject-Header-Begin-->
<H1>Re: [MUD-Dev] Storing tokens with flex & 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 & bison</LI>
<LI><em>From</em>: Christer Enfors <<A HREF="mailto:enfors#swipnet,se">enfors#swipnet,se</A>></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:
> On Fri, 31 Dec 1999, Christer Enfors wrote:
>
> > I'm not sure if this is the proper forum for this kind of question, but I
> > can't find any mailing lists for lex & yacc, and it is a MUD I'm
> > developing...
> >
> > I want to write a MUD server, and for this I want to develop a LPC-like
> > interpreting programming (or call it scripting if you like) language with
> > flex and bison.
> >
> > When flex reads a file, would it be a good idea to store the tokens
> > returned from yylex() in a list? I was thinking one list for each function
> > definition, and then having bison read from that list when executing that
> > function, instead of reading directly from the file using flex?
> >
> > If so, how would I get yylex() to return tokens from my list instead of
> > 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.
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.
> > Or should I simply read the function definition from the file with flex
> > 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.
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.
> > Maybe someone could point me to a lex & yacc tutorial that includes
> > writing an interpreted language that allowes user defined functions
> > written in that language, since that is basically what I'm trying to do
> > myself.
>
> The O'Reilly Lex & 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 & bison</A></STRONG>
<UL><LI><EM>From:</EM> Chris Turner <christ#rd,bbc.co.uk></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 & bison</A></STRONG>
</LI>
<LI>Next by Date:
<STRONG><A HREF="msg00011.html">Re: [MUD-Dev] Storing tokens with flex & bison</A></STRONG>
</LI>
<LI>Prev by thread:
<STRONG><A HREF="msg00005.html">Re: [MUD-Dev] Storing tokens with flex & bison</A></STRONG>
</LI>
<LI>Next by thread:
<STRONG><A HREF="msg00006.html">Re: [MUD-Dev] Storing tokens with flex & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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 & 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>
[ <a href="../">Other Periods</a>
| <a href="../../">Other mailing lists</a>
| <a href="/search.php3">Search</a>
]
</center>
<hr>
</body>
</html>