home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18172 < prev    next >
Encoding:
Text File  |  1992-12-20  |  3.8 KB  |  67 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!spool.mu.edu!umn.edu!csus.edu!netcom.com!erc
  3. From: erc@netcom.com (Eric Smith)
  4. Subject: Re: compiler error reporting
  5. Message-ID: <1992Dec18.101307.19478@netcom.com>
  6. Organization: Netcom - Online Communication Services (408 241-9760 guest)
  7. References: <BzFq6w.MHB@world.std.com>
  8. Date: Fri, 18 Dec 1992 10:13:07 GMT
  9. Lines: 56
  10.  
  11. In article <BzFq6w.MHB@world.std.com> btarbox@world.std.com (Brian J Tarbox) writes:
  12. >Why are c++ compilers so bad about reporting errors?
  13.  
  14. My C++ parser doesn't have that problem, and in fact its first
  15. application is "C++ Clarifier" which is a program to give you a "second
  16. opinion" error message to compare with your compiler's error message,
  17. in those cases where the compiler's error message is so cryptic and
  18. frustrating that it seems like it might waste a lot of your time
  19. finding out what it means.  I'm going to start beta testing C++
  20. Clarifier in about a month or so, with the Microsoft 32-bit C++
  21. compiler as the initial platform.  Would you like to be a beta tester?
  22.  
  23. Some people might find it hard to believe that I would put in all the
  24. considerable time and effort to develop a C++ parser just to check for
  25. errors, and they would be right, because C++ Clarifier is actually just
  26. an application I thought up after getting my parser working.  My
  27. original and continuing intent was/is to develop the world's best C++
  28. development environment.  After the C++ Clarifier beta test is started,
  29. I will be working on an extended preprocessor, a class browser, and
  30. several other programs that will use my parser, but the development
  31. environment as a whole won't be done until after most of its parts are
  32. already widely used.
  33.  
  34. As for your question, why are C++ compilers so bad about reporting
  35. errors, I think the main reason is that C++ is one of the hardest
  36. languages to parse.  First, preprocessing is considered a separate
  37. stage, and most C++ parsers keep it separate such that they lose
  38. context information between the stages because there is no convenient
  39. way to retain it.  Second, there are a lot of complications and ways to
  40. lose context information in the main parser.  For example, when parsing
  41. a class, the inline functions have to be parsed at the end of the
  42. class, even if they appear earlier, so they will see the declarations
  43. that appear after them in the class.  But if an error is discovered in
  44. one of those functions, the parser will have already parsed to the end
  45. of the class.  A lot of parsers designed without enough consideration
  46. for error reporting are unable to place such errors in their correct
  47. location because they don't keep track of the original location when
  48. they move the functions to the end of the class.  There are a lot of
  49. other examples of where the parser can go wrong and lose the error
  50. context.  But the main problem is really that making the parser work at
  51. all is very hard, and when it finally works the programmers are
  52. reluctant to spend a lot of time and effort rewriting it to improve its
  53. ability to place errors in their correct locations.
  54.  
  55. I spent considerable time and effort solving those problems in my
  56. parser, and one of the reasons why I was willing and able to do so was
  57. that I used object oriented programming, which makes rewriting the
  58. code, redesigning it, rewriting it again, etc., much easier.  For a
  59. program as complicated as a C++ parser, there is no way to get it right
  60. the first time.  It's just too complicated.  So anyone who wants to
  61. write a high quality C++ parser had better plan on redesigning and
  62. rewriting it several times, and had better design the original code in
  63. such a way as to make it easy to rewrite major parts of it as many
  64. times as needed to get it right.  It's also very important to make it
  65. as fast as possible, and that usually requires redesigning and
  66. rewriting major parts of it at least a few extra times.
  67.