home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14603 < prev    next >
Encoding:
Text File  |  1992-08-27  |  2.5 KB  |  56 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!cs.utexas.edu!tamsun.tamu.edu!bpb9204
  3. From: bpb9204@tamsun.tamu.edu (Brent)
  4. Subject: Re: yacc/lex -like utilities for thinkC?
  5. Message-ID: <1992Aug27.143139.12460@tamsun.tamu.edu>
  6. Organization: Texas A&M Univ., Inc.
  7. References: <1992Aug26.204509.23323@cybernet.cse.fau.edu>
  8. Date: Thu, 27 Aug 1992 14:31:39 GMT
  9. Lines: 45
  10.  
  11. pollansw@cse.fau.edu (Warren Pollans) writes:
  12. |Are there utilities like the unix yacc and lex available for use
  13. |with thinkC?  I'm taking a compiler-writing course and would like
  14. |to do as much as possible of the project (1000-1500 lines) at home
  15. |on my SE (2.5M, probably expanded to 4M).  At worst, I can write
  16. |and test modules at home and put the whole thing together on the
  17. |unix system (sunOS).
  18.  
  19. Yes, there are a few.  For lex, there is GNU's Flex (fast lexer generator)
  20. and for yacc there is MacYacc, GNU's bison, and Berkeley yacc (byacc).
  21.  
  22. MacYacc may not even be available anymore; it was free but some say it was
  23. buggy.  I never used it for anything.
  24.  
  25. I have found that Bison works great.  While it produces huge C source files,
  26. they compile to almost half of what an AT&T yacc parser would!  Also, bison
  27. has been reengineered (not a port of AT&T yacc) so it's much more efficient.
  28. AND, bison can be made compatible with yacc.
  29.  
  30. I have never used byacc.
  31. GNU's flex works fine for me, also.
  32.  
  33. Now that I have the quick rundown of the available tools, I want to make some
  34. comments.  First, if you use the GNU tools, be aware they come with certain
  35. licenses and policies that you may not like.  See their Copyright files
  36. (included with the programs) for details.  Personally, I didn't have a problem
  37. with their policies.
  38.  
  39. Second, you can quickly develop a compiler with flex and bison.  For my
  40. compiler design project, we had to write a compiler for a subset of pascal.
  41. Within two hours I had a working flex/bison-based parser.  Unfortunately,
  42. we had to hand-code everything (and we really learned how LL(1) & LALR(1)
  43. parsers click!).  ;-)
  44.  
  45. If you have to hand-code your scanner ("lexer") and parser, you can still 
  46. find flex and bison great for testing.  Use both tools in the beginning to
  47. get a feel for the grammar you are parsing; it turned out our prof gave us
  48. many ambiguities in our language, which added about 50% more rules to the
  49. original grammar.  Once you have the grammar figured out, hand-code your
  50. lexer and test it with the bison parser.  Finally, code the parser.
  51.  
  52. Hope this helps someone.
  53.  
  54. -Brent, N5VMG
  55.  bpb9204@tamsun.tamu.edu
  56.