Xref: utzoo comp.lang.c:31051 comp.unix.questions:24583 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!hellgate.utah.edu!helios.ee.lbl.gov!ucsd!pacbell.com!pacbell!att!dptg!lzga!bogatko From: bogatko@lzga.ATT.COM (George Bogatko) Newsgroups: comp.lang.c,comp.unix.questions Subject: Re: Using Lex (and Yacc) on a string. Summary: heres one way Message-ID: <2002@lzga.ATT.COM> X-Local-Date: 10 Aug 90 09:42:20 PDT Date: 10 Aug 90 16:42:20 GMT References: <1990Aug10.012927.5558@basho.uucp> Organization: AT&T BL Middletown/Lincroft NJ USA Lines: 39 In article <1990Aug10.012927.5558@basho.uucp>, john@basho.uucp (John Lacey) writes: > Has anyone done this, or see a way to do it, or know a way to do it, or .... Put these lines in your lex file after the #include lines %{ #include #include extern char *mis_ptr; #undef input #undef unput # define input() (*mis_ptr=='\n'?0:*mis_ptr++) # define unput(c) (*--mis_ptr=(c) ) %} Now have a char buff called myinputstring char myinputstring[100]; do the following in main: char *mis_ptr; main() { for(;;) { gets(buf); mis_ptr = buf; yylex(); } } I think you get the picture now? GB