Streamlining Control Flow Graph Construction with DCFlow

  • Mark Hills
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8706)


A control flow graph (CFG) is used to model possible paths through a program, and is an essential part of many program analysis algorithms. While programs to construct CFGs can be written in meta-programming languages such as Rascal, writing such programs is currently quite tedious. With the goal of streamlining this process, in this paper we present DCFlow, a domain-specific language and Rascal library for defining control flow rules and building control flow graphs. Control flow rules in DCFlow are defined declaratively, based directly on the abstract syntax of the language under analysis and a number of operations representing types of control flow. Standard Rascal code is then generated based on the DCFlow definition. This code makes use of the DCFlow libraries to build CFGs for programs, which can then be visualized or used inside program analysis algorithms. To demonstrate the design of DCFlow we apply it to Pico—a very simple imperative language—and to a significant subset of PHP.


Relational Algebra Abstract Syntax Control Flow Graph Attribute Grammar Exit Node 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Aho, A., Kernighan, B., Weinberger, P.: Awk - A Pattern Scanning and Processing Language. Software–Practice and Experience 9(4), 267–280 (1979)CrossRefzbMATHGoogle Scholar
  2. 2.
    Allen, F.E.: Control Flow Analysis. In: Proceedings of a Symposium on Compiler Optimization, pp. 1–19. ACM, New York (1970)CrossRefGoogle Scholar
  3. 3.
    Basten, H.J.S., Klint, P.: DeFacto: Language-Parametric Fact Extraction from Source Code. In: Gašević, D., Lämmel, R., Van Wyk, E. (eds.) SLE 2008. LNCS, vol. 5452, pp. 265–284. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  4. 4.
    Beyer, D., Noack, A., Lewerentz, C.: Simple and efficient relational querying of software structures. In: Proceedings of the 10th Working Conference on Reverse Engineering, pp. 216–225 (2003)Google Scholar
  5. 5.
    Beyer, D., Noack, A., Lewerentz, C.: Efficient relational calculation for software analysis. IEEE Transactions on Software Engineering 31(2), 137 (2005)CrossRefGoogle Scholar
  6. 6.
    Ekman, T., Hedin, G.: The JastAdd system - modular extensible compiler construction. Science of Computer Programming 69(1–3), 14–26 (2007)CrossRefzbMATHMathSciNetGoogle Scholar
  7. 7.
    Hills, M., Klint, P.: PHP AiR: Analyzing PHP Systems with Rascal. In: Proceedings of CSMR-WCRE 2014, pp. 454–457. IEEE (2014)Google Scholar
  8. 8.
    Hills, M., Klint, P., Vinju, J.J.: Meta-language Support for Type-Safe Access to External Resources. In: Czarnecki, K., Hedin, G. (eds.) SLE 2012. LNCS, vol. 7745, pp. 372–391. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  9. 9.
    Holt, R.: Binary Relational Algebra Applied to Software Architecture. CSRI 345. University of Toronto (March 1996)Google Scholar
  10. 10.
    Izmaylova, A., Klint, P., Shahi, A., Vinju, J.J.: M3: An Open Model For Measuring Code Artifacts. Technical Report arXiv-1312.1188, CWI (December 2013)Google Scholar
  11. 11.
    Johnson, S.C.: Yacc: Yet Another Compiler-Compiler. Technical Report CS TR 32, Bell Labs (1975)Google Scholar
  12. 12.
    Jourdan, M., Parigot, D., Julié, C., Durin, O., Bellec, C.L.: Design, Implementation and Evaluation of the FNC-2 Attribute Grammar System. In: Proceedings of PLDI 1990, pp. 209–222 (1990)Google Scholar
  13. 13.
    Kats, L.C.L., Visser, E.: The Spoofax Language Workbench. In: OOPSLA 2010 Companion, pp. 237–238. ACM (2010)Google Scholar
  14. 14.
    Klint, P.: Using Rscript for Software Analysis. In: Working Session on Query Technologies and Applications for Program Comprehension, QTAPC 2008 (2008)Google Scholar
  15. 15.
    Klint, P., van der Storm, T., Vinju, J.: EASY Meta-programming with Rascal. In: Fernandes, J.M., Lämmel, R., Visser, J., Saraiva, J. (eds.) Generative and Transformational Techniques in Software Engineering III. LNCS, vol. 6491, pp. 222–289. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  16. 16.
    Klint, P., van der Storm, T., Vinju, J.J.: RASCAL: A Domain Specific Language for Source Code Analysis and Manipulation. In: Proceedings of SCAM 2009, pp. 168–177. IEEE (2009)Google Scholar
  17. 17.
    Lesk, M.: Lex - a lexical analyzer generator. Technical Report CS TR 39, Bell Labs (1975)Google Scholar
  18. 18.
    Moonen, L.: Data Flow Analysis for Reverse Engineering. Master’s thesis, University of Amsterdam (1996)Google Scholar
  19. 19.
    Müller, H., Klashinsky, K.: Rigi – a system for programming-in-the-large. In: Proceedings of ICSE 1988, pp. 80–86 (April 1988)Google Scholar
  20. 20.
    Murphy, G., Notkin, D.: Lightweight source model extraction. In: Proceedings of FSE 1995, pp. 116–127. ACM Press, New York (1995)Google Scholar
  21. 21.
    Murphy, G.C., Notkin, D.: Lightweight Lexical Source Model Extraction. ACM TOSEM 5(3), 262–292 (1996)CrossRefGoogle Scholar
  22. 22.
    Paakki, J.: Attribute grammar paradigms - a high-level methodology in language implementation. ACM Computing Surveys 27(2), 196–255 (1995)CrossRefGoogle Scholar
  23. 23.
    Sloane, A.M.: Lightweight Language Processing in Kiama. In: Fernandes, J.M., Lämmel, R., Visser, J., Saraiva, J. (eds.) GTTSE 2009. LNCS, vol. 6491, pp. 408–425. Springer, Heidelberg (2011)Google Scholar
  24. 24.
    Söderberg, E., Ekman, T., Hedin, G., Magnusson, E.: Extensible intraprocedural flow analysis at the abstract syntax tree level. Science of Computer Programming 78(10), 1809–1827 (2013)CrossRefGoogle Scholar
  25. 25.
    van den Brand, M., Bruntink, M., Economopoulos, G., de Jong, H., Klint, P., Kooiker, T., van der Storm, T., Vinju, J.: Using The Meta-environment for Maintenance and Renovation. In: Proceedings of CSMR 2007, pp. 331–332. IEEE (2007)Google Scholar
  26. 26.
    den van Brand, M.G.J., van Deursen, A., Heering, J., de Jong, H.A., de Jonge, M., Kuipers, T., Klint, P., Moonen, L., Olivier, P.A., Scheerder, J., Vinju, J.J., Visser, E., Visser, J.: The ASF+SDF Meta-environment: A Component-Based Language Development Environment. In: Wilhelm, R. (ed.) CC 2001. LNCS, vol. 2027, pp. 365–370. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  27. 27.
    Vankov, I.: Relational approach to program slicing. Master’s thesis, University of Amsterdam (2005)Google Scholar
  28. 28.
    Wachsmuth, G.H., Konat, G.D.P., Vergu, V.A., Groenewegen, D.M., Visser, E.: A Language Independent Task Engine for Incremental Name and Type Analysis. In: Erwig, M., Paige, R.F., Van Wyk, E. (eds.) SLE 2013. LNCS, vol. 8225, pp. 260–280. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  29. 29.
    Wyk, E.V., Bodin, D., Gao, J., Krishnan, L.: Silver: An extensible attribute grammar system. Science of Computer Programming 75(1-2), 39–54 (2010)CrossRefzbMATHMathSciNetGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Mark Hills
    • 1
  1. 1.East Carolina UniversityGreenvilleUSA

Personalised recommendations