How to Calculate Software Metrics for Multiple Languages Using Open Source Parsers

  • Andrea Janes
  • Danila Piatov
  • Alberto Sillitti
  • Giancarlo Succi
Part of the IFIP Advances in Information and Communication Technology book series (IFIPAICT, volume 404)

Abstract

Source code metrics help to evaluate the quality of the code, for example, to detect the most complex parts of the program. When writing a system which calculates metrics, especially when it has to support multiple source code languages, the biggest problem which arises is the creation of parsers for each supported language. In this paper we suggest an unusual Open Source solution, that avoids creating such parsers from scratch. We suggest and explain how to use parsers contained in the Eclipse IDE as parsers that support contemporary language features, are actively maintained, can recover from errors, and provide not just the abstract syntax tree, but the whole type information of the source program. The findings described in this paper provide to practitioners a way to use Open Source parsers without the need to deal with parser generators, or to write a parser from scratch.

References

  1. 1.
    Sillitti, A., Janes, A., Succi, G., Vernazza, T.: Measures for mobile users: an architecture. J. Syst. Archit. 50, 393–405 (2004)CrossRefGoogle Scholar
  2. 2.
    Jermakovics, A., Scotto, M., Sillitti, A., Succi, G.: Lagrein: Visualizing user requirements and development effort. In: 15th IEEE International Conference on Program Comprehension, pp. 293–296 (June)Google Scholar
  3. 3.
    Jermakovics, A., Moser, R., Sillitti, A., Succi, G.: Visualizing software evolution with lagrein. In: Companion to the 23rd ACM SIGPLAN Conference on Object-Oriented Programming Systems Languages and Applications, OOPSLA Companion 2008, pp. 749–750. ACM, New York (2008)CrossRefGoogle Scholar
  4. 4.
    di Bella, E., Sillitti, A., Succi, G.: A multivariate classification of open source developers. Information Sciences 221, 72–83 (2013)CrossRefGoogle Scholar
  5. 5.
    Janes, A., Succi, G.: The dark side of agile software development. In: Proceedings of the ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, Onward! 2012, pp. 215–228. ACM, New York (2012)CrossRefGoogle Scholar
  6. 6.
    Werther, B., Conway, D.: A modest proposal: C++ resyntaxed. ACM SIGPLAN Notices 31, 74–82 (1996)CrossRefGoogle Scholar
  7. 7.
    Birkett, A.: Parsing C++ (2001), http://www.nobugs.org/developer/parsingcpp/index.html (accessed April 14, 2012)
  8. 8.
    Piatov, D., Janes, A., Sillitti, A., Succi, G.: Using the Eclipse C/C++ development tooling as a robust, fully functional, actively maintained, open source C++ parser. In: Hammouda, I., Lundell, B., Mikkonen, T., Scacchi, W. (eds.) OSS 2012. IFIP AICT, vol. 378, pp. 399–399. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  9. 9.
    Ritchie, D.M.: The development of the C language, pp. 201–208 (1993)Google Scholar
  10. 10.
    Russo, B., Scotto, M., Sillitti, A., Succi, G.: Agile Technologies in Open Source Development. Information Science Reference - Imprint of: IGI Publishing (2009)Google Scholar
  11. 11.
    clang: a C language family frontend for LLVM, http://clang.llvm.org (accessed February 01, 2013)
  12. 12.
    Diggins, C.: cpp-ripper, An open-source C++ parser written in C# (2012), http://code.google.com/p/cpp-ripper/
  13. 13.
    McPeak, S.: Elsa: The Elkhound-based C/C++ parser, http://scottmcpeak.com/elkhound/sources/elsa/ (accessed April 14, 2012)
  14. 14.
    GCC Development Team, GCC, the GNU Compiler Collection, http://gcc.gnu.org (accessed April 14, 2012)
  15. 15.
    King, B.: GCC-XML, the XML output extension to GCC, http://www.gccxml.org (accessed April 14, 2012)
  16. 16.
    Eclipse CDT (C/C++ Development Tooling) (2012), http://www.eclipse.org/cdt
  17. 17.
    Terceiro, A., Costa, J., Miranda, J., Meirelles, P., Rios, L.R., Almeida, L., Chavez, C., Kon, F.: Analizo: an extensible multi-language source code analysis and visualization toolkit. In: Brazilian Conference on Software: Theory and Practice (CBSoft) – Tools, Salvador-Brazil (2010)Google Scholar
  18. 18.
    Doxygen, http://www.stack.nl/~dimitri/doxygen/ (accessed February 01, 2013)
  19. 19.
    stackoverflow.com, How much time would it take to write a C++ compiler using flex/yacc?, http://stackoverflow.com/questions/1961604 (accessed February 01, 2013)
  20. 20.
    First revision of clang, http://llvm.org/viewvc/llvm-project?view=rev&revision=1 (accessed February 01, 2013)
  21. 21.
    Lattner, C.: Llvm 2.6 release! (2009), http://lists.cs.uiuc.edu/pipermail/llvm-announce/2009-October/000033.html (accessed February 01, 2013)
  22. 22.
    GCC-XML, the XML output extension to GCC repository, https://github.com/gccxml/gccxml (accessed February 01, 2013)
  23. 23.
    Eclipse CDT (C/C++ Development Tooling) repository, http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/refs/tags
  24. 24.
    cpp-ripper list of repository changes, https://code.google.com/p/cpp-ripper/source/list (accessed February 01, 2013)
  25. 25.
    Elkhound: A glr parser generator and elsa: An elkhound-based c++ parser, http://scottmcpeak.com/elkhound/ (accessed February 01, 2013)
  26. 26.
    GCC-XML, Frequently Asked Questions, http://www.gccxml.org/HTML/FAQ.html (accessed February 01, 2013)
  27. 27.
    Mitchell, M.: GCC Bugzilla – Bug 18279, http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18279 (accessed February 01, 2013)
  28. 28.
    Lex – A Lexical Analyzer Generator, http://dinosaur.compilertools.net/lex/ (accessed February 01, 2013)
  29. 29.
    The NRefactory library, https://github.com/icsharpcode/SharpDevelop/wiki/NRefactory (accessed February 01, 2013)
  30. 30.
    Petrinja, E., Nambakam, R., Sillitti, A.: Introducing the opensource maturity model. In: Proceedings of the 2009 ICSE Workshop on Emerging Trends in Free/Libre/Open Source Software Research and Development, pp. 37–41. IEEE Computer Society, Washington, DC (2009)CrossRefGoogle Scholar
  31. 31.
    Sillitti, A., Janes, A., Succi, G., Vernazza, T.: Monitoring the development process with eclipse. In: Proceedings of the International Conference on Information Technology: Coding and Computing, ITCC 2004, vol. 2, pp. 133–134 (April 2004)Google Scholar
  32. 32.
    Scotto, M., Sillitti, A., Succi, G., Vernazza, T.: A non-invasive approach to product metrics collection. J. Syst. Archit. 52, 668–675 (2006)CrossRefGoogle Scholar

Copyright information

© IFIP International Federation for Information Processing 2013

Authors and Affiliations

  • Andrea Janes
    • 1
  • Danila Piatov
    • 1
  • Alberto Sillitti
    • 1
  • Giancarlo Succi
    • 1
  1. 1.CASEFree University of BolzanoItaly

Personalised recommendations