home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16408 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.5 KB  |  81 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!cs.utexas.edu!uwm.edu!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!sdd.hp.com!spool.mu.edu!agate!netsys!news!lsi!mhost!cl301!ameesh
  2. From: ameesh@lsil.com (Ameesh Desai)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Need Yacc & Lex retargeted to C++
  5. Message-ID: <1992Nov16.201658.2862@lsil.com>
  6. Date: 16 Nov 92 20:16:58 GMT
  7. References: <1992Nov13.154107.21091@murdoch.acc.Virginia.EDU>
  8. Sender: news@lsil.com (news caster)
  9. Reply-To: ameesh@lsil.com
  10. Organization: LSI Logic Corporation
  11. Lines: 67
  12. Nntp-Posting-Host: cl301
  13.  
  14. In article 21091@murdoch.acc.Virginia.EDU, cgh6m@darwin.clas.Virginia.EDU (Craig G. Hocker) writes:
  15. >This seems to be a topic of some interest, so I will mention a 
  16. >C++ Parser Class Kit I came across by accident yesterday while
  17. >downloading another file. Nobody has mentioned it.
  18. >
  19. >anonymous ftp to  export.lcs.mit.edu
  20. >
  21. >    contrib/yacc.shar.Z
  22. >
  23. >
  24. >warning: it's a beta version, but the author does seem to be actively
  25. >soliciting people to modify and send him enhancements.
  26. >
  27. >I can't comment on it, since I haven't tried to do anything with it
  28. >yet.
  29. >
  30. >cgh6m@darwin.clas.virginia.edu
  31. >Craig G. Hocker
  32. >NSF-Center for Biological Timing
  33. >University of Virginia, Charlottesville, VA 22901
  34. >---- yep, that means I'm a scientist and not a computer jock! ----
  35.  
  36.  
  37. The implementation seems to encapsulate only the global yacc variables within a 
  38. C++ class. In effect providing a C++ "wrapper" to yacc calls and vars.
  39.  
  40. The problem with yacc is not its variables. Its making yacc understand C++ 
  41. class definations. You should ideally be able to write stuff like...
  42.  
  43. %{
  44.  
  45. class A {   // some C++ class
  46. ...
  47. public:
  48.     A();        // see note below ... this would cause problems with yacc
  49. };
  50.  
  51. %}
  52.  
  53. %union
  54. {
  55. int ival;
  56. float fval;
  57. char *sval
  58. A aclass;         // make this work !
  59. }
  60.  
  61. %type <aclass> rule_that_returns_a_class
  62.  
  63. ....
  64. %%
  65.  
  66. The fact that a class contains a ctor/dtor should not prevent it
  67. from being returned. The current yacc implementation depends on union for
  68. declaring the return type, and C++ will not allow a class with a ctor/dtor
  69. to be part of the union !
  70.  
  71.  
  72. Ameesh
  73.  
  74.  
  75. ---
  76. ______________________________     o__            
  77. | _   /|     Ameesh Desai     \    ,>/_                              
  78. | \`O.o'     LSI Logic Corp.   \__(_)`(_)_              email: ameesh@lsil.com
  79. | =(_|_)=    MS E192, 1501 McCarthy Blvd. \             fax  : (408) 433-6802
  80. |____U_______Milpitas, CA 95035____________\____________voice: (408) 433-4097 
  81.