yacc & lex - cupla questions

Peter Gross pag at hao.hao.ucar.edu
Mon Jul 30 03:31:32 AEST 1990


In article <1990Jul26.175831.1216 at uicbert.eecs.uic.edu> woodward at 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 at scg.boulder.co.us	[MX-able]
..ncar!scg!pag		[uucp]
pag%scg at ncar.ucar.edu	[Internet]



More information about the Comp.unix.wizards mailing list