home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / linux / 6448 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  2.4 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!mips!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!uw-beaver!news.u.washington.edu!serval!phys1.physics.wsu.edu!hlu
  2. From: hlu@phys1.physics.wsu.edu (Hongjiu Lu)
  3. Newsgroups: comp.os.linux
  4. Subject: Re: yacc and lex
  5. Message-ID: <1992Jul22.210710.8123@serval.net.wsu.edu>
  6. Date: 22 Jul 92 21:07:10 GMT
  7. References: <1992Jul21.164738.1@mcclb0.med.nyu.edu> <WEILER.92Jul21213719@crabapple.cis.ohio-state.edu> <1992Jul22.135605.12853@advtech.uswest.com>
  8. Sender: news@serval.net.wsu.edu (USENET News System)
  9. Organization: Washington State University
  10. Lines: 47
  11.  
  12. In article <1992Jul22.135605.12853@advtech.uswest.com>, mcain@copper (Michael Cain) writes:
  13. |> In article <WEILER.92Jul21213719@crabapple.cis.ohio-state.edu> weiler@crabapple.cis.ohio-state.edu (Jerry Weiler) writes:
  14. |> >In article <1992Jul21.164738.1@mcclb0.med.nyu.edu> ramirez@mcclb0.med.nyu.edu writes:
  15. |> >
  16. |> >> I would like to know if anybody has ported yacc and lex
  17. |> >> over to linux. If yes, please let me know where I can find it.
  18. |> >
  19. |> >You should use bison and flex. bison is the GNU replacement for yacc
  20. |> >and flex is the GNU replacement for lex. They're faster, more flexible
  21. |> >and all around better. Bison and flex should be able to handle any
  22. |> >grammer yacc and lex do (any well written one, that is)
  23. |> 
  24. |> Flex does have one significant handicap when compared to lex: in lex,
  25. |> the default i/o functions are actually macros, which can be #undef'ed
  26. |> and replaced with real functions of the same name that can get input
  27. |> from anywhere; flex has real functions that insist on reading from
  28. |> files, and trying to replace these is semi-major surgery...
  29. |> 
  30.  
  31. Did the FSF just release a new flex? I used flex 2.3.7. I did this
  32. ---------
  33. #undef ECHO
  34. #define ECHO    cout.put ((char *) yytext, yyleng)
  35.  
  36. #undef YY_INPUT(buf,result,max_size)
  37. #define YY_INPUT(buf,result,max_size) \
  38.   {char c; cin.get (c); result = (cin.eof ()) ? YY_NULL : (buf[0] = c, 1);}
  39. ---------
  40.  
  41. As you can see, that was for C++. But the story is the same. I haven't found
  42. what I couln't do with flex. Sometimes, you just have to read those docs.
  43. BTW, I ran it with flex -I for interactive use.
  44.  
  45.  
  46. |> I regularly seem to want to parse stuff and don't want to let the
  47. |> analyzer built by flex handle my low-level file i/o...
  48. |> 
  49.  
  50. I think you can do that with flex 2.3.7. Check those docs.
  51.  
  52. |> Mike Cain
  53. |> U S WEST Advanced Technologies
  54. |> mcain@advtech.uswest.com
  55.  
  56. -- 
  57. H.J.
  58. Gcc/libc maintainer for Linux.
  59.