Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!ncar!hao.hao.ucar.edu!pag From: pag@hao.hao.ucar.edu (Peter Gross) Newsgroups: comp.unix.wizards Subject: Re: yacc & lex - cupla questions Keywords: yacc lex compiler parse Message-ID: <8122@ncar.ucar.edu> Date: 29 Jul 90 17:31:32 GMT References: <1990Jul26.175831.1216@uicbert.eecs.uic.edu> Sender: news@ncar.ucar.edu Distribution: comp Organization: High Alititude Observatory/NCAR, Boulder CO Lines: 39 In article <1990Jul26.175831.1216@uicbert.eecs.uic.edu> woodward@uicbert.eecs.uic.edu writes: > >i have been trying to parse a straightforward stream of bytes using the >c-preprocessors lex & yacc. being a new user of these utilities, i have >a couple of problems for which i'd like to solicit your suggestions: > >--------------------------------------------------------------------- >1.) how does one redefine the i/o in a yacc/lex piece of code? i.e. >the code which is generated defaults to stdin and stdout for input and >output, respectively. i'd like to redefine these defaults w/o having >to hack on the intermediate c-code, since this is a live production >project; i'd like to be able to update and modify the program simply by >saying "make". >any comments or suggestions would be most heartily appreciated. Many respondents have given excellent suggestions for this question, the general idea being to the reassign the FILE *'s yyin and yyout. How about the closely related, but not quite the same problem of wanting to do processing to the input (or output): eg., to strip off the high order bit? I have an application with the following condition: input from tty port, RAW, contains 7-bit binary info, but generates even parity (I have no control over this). Have to strip off the parity bit. Any suggestions? Note that I prefer not to redefine yyinput() due to the yyunput() problem. (Maybe that's not such a big deal -- haven't looked into it yet). On a related, but tangential matter -- anyone know of some public domain line-discipline (similar to, but much more flexible than bk(4)) for high speed input (no processing 'cept the previously mentioned parity bit stripping)? Currently running under SunOS 3.5. Thanks to everyone who answered the original question -- lot's of good responses. -- --peter gross pag@scg.boulder.co.us [MX-able] ..ncar!scg!pag [uucp] pag%scg@ncar.ucar.edu [Internet]