Evaluation of cint

Objective:

To see if cint has good design and assess the cost of maintenance

What I have done:

  • Take source code of version 5.13.42
  • Take a look at the parser code
  • Build it and play around
  • Disclaimer: I'm not an expert in cint

    First impression:

  • > 80,000 lines of code written primarily by a single author (the author must have applied tremendous self-discipline in writing it)
  • cint is able to interpret itself!
  • Closer look:

  • Lexical analyzer and parser are completely hard coded together
  • The parser can be categorized as recursive-descend parser
  • Advantage of recursive descend parser is its simplicity -- the implementation is a direct mapping from the grammar of the target language.
  • Pure recursive-descend parser only applies to LL(0) language, which C is not.
  • Recursive-descend parser with ability of looking ahead k tokens, such as the one used in cint, applies to LL(k) language, which C is not, either.
  • To use recursive descend parser to parse C (not to mentioning about C++), a lot of patch-up work has to be done. In cint such work is scattered through out the code.(messy-messy!)
  • cint claims to cover 95% of ANSI C and 85% of ANSI C++ 3.0, but it doesn't specifically define the 5% and 15% that it doesn't cover.
  • Lack of a formal design method could be a maintenance nightmare for code of this size. (No regular expression definition of lexical elements, nor grammar definition of the syntax)
  • According to its history, it started from a subset of C to most of C then to C++. This implies the final design was not complete in the first place. This could very well, but not necessarily, mean the initial design may prevent the completeness of the final design. (In the source code, there are many traces of ad-hoc code which were added later on.)
  • Concluding remarks

  • cint is packed with a lot of features
  • The author seems to be a very good programmer, but he doesnŐt work for us directly.
  • Do not underestimate the cost of modifying/improving/debugging the code if it is done by someone else.
  • If cint is to be used, it should be used as- is since the cost of maintenance would be high.
  • The question is, is there any other alternative to cint?