Xref: utzoo comp.lang.c:39154 comp.unix.questions:31175 comp.unix.wizards:25513 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!caen!ox.com!math.fu-berlin.de!unidui!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.lang.c,comp.unix.questions,comp.unix.wizards Subject: FAQ for lex + yacc? (was Re: using lex with strings, not files) Keywords: lex, yacc, strings Message-ID: <1137@mwtech.UUCP> Date: 9 May 91 16:43:56 GMT References: <5384@lectroid.sw.stratus.com> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 55 In article <5384@lectroid.sw.stratus.com> leavitt@mordor.hw.stratus.com (Will Leavitt) writes: > >Hi- > I'd like to use lex & yacc to parse strings within an application, but they >seem to be hardwired to take their input from stdin. What is the cannonical >way to get them to work on a string? Thanks! > > -will In the last few weeks there have been some more questions concerning lex + yacc. Certain questions seem to come up again and again. Not quite a year ago I posted two rather lengthy articles in which I tried to explain the following topics: 1.) How does one redefine the I/O in a yacc/lex piece of code? 2.) How to make lex and yacc work smoothly together with make, when separate compilation of individual modules is desired. 3.) My grammar contains the following rule line3 : A B C { yacc action sequence } which indicates that the construct line3 is composed of the 3 tokens A B and C, in that order. How can i now assign the string values which originally constituted the tokens of A, B, and C into local variables of my choice? Since I originally posted my answers here, I composed the articles into one and polished this one up a little (whow, I even cared to use "spell" :-)). If similar questions appeared here (and I had time to read this group), I usually offered to the poster to mail him my answers, though the latter is quite expensive for me (it's 16 KB mail from Europe to USA, which costs me about $7 per copy - not too much for a single copy but it sums up). Now I dare to use some bandwidth here again with *my* questions: a) Should I turn my answers to above named questions into a regular FAQ posting for lex + yacc? b) If you think I SHOULD post the stuff on a regular basis, which group would be appropriate for such a posting and in which intervals should I post it. c) If you DON'T think I should post, where would be a good place to deposit my answers, so that the ones who are interested could obtain it from there without the need for me to mail 16 KB individually. Note that I can NOT ftp but I would well like to incorporate updates from time to time. d) What other topics (besides the above ones) would you like to see in a FAQ for lex + yacc. Note that I don't want to write another book about lex + yacc right now (though, maybe, I'll do that some day :-)), but only want to shed a little light in some of the darker corners. Thanks for listening so far. -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83