skip to main content
10.1145/2889420.2889422acmotherconferencesArticle/Chapter ViewAbstractPublication PagesrwdslConference Proceedingsconference-collections
research-article

Automatic Generation of Code Analysis Tools: The CastQL Approach

Published: 12 March 2016 Publication History

Abstract

Source code analysis and manipulation tools have become an essential part of software development processes. Automating the development of such tools can heavily reduce development time, effort and cost. This paper proposes a framework for the efficient development of code analysis software. A tool for automatically generating the front end of analysis tools for a given language grammar is proposed. The proposed approach can be applied to any language that can be described using the BNF notation. The proposed framework also provides a domain specific language to concisely express queries on the internal representation generated by the front end. This language tackles the problem of writing complex code in a general purpose programming language in order to retrieve information from the internal representation. The approach has been evaluated through two different realistic usage scenarios applied to a number of different benchmark applications. The front end generator has also been tested for twenty input grammars. In all cases the software generated by the proposed framework functions according to the input grammar while the development time has been reduced on average down to 12% compared to equivalent handwritten implementations. The experimental results give evidence that the use of the proposed framework can heavily reduce the relevant design effort and cost.

References

[1]
T. Alves, J. Hage, and P. Rademaker. A Comparative Study of Code Query Technologies. In 2011 11th IEEE International Working Conference on Source Code Analysis and Manipulation (SCAM), pages 145--154, Sept. 2011.
[2]
P. Anderson and T. Teitelbaum. Software inspection using CodeSurfer. In Proceedings of the 1st Workshop on Inspection in Software Engineering (WISE), Paris, France, July 2001.
[3]
G. Antoniol, M. Di Penta, and E. Merlo. YAAB (Yet another AST browser): using OCL to navigate ASTs. In 11th IEEE International Workshop on Program Comprehension, 2003, pages 13--22, May 2003.
[4]
A. Arusoaie and D. Vicol. Automating Abstract Syntax Tree Construction for Context Free Grammars. In 2012 14th International Symposium on Symbolic and Numeric Algorithms for Scientific Computing (SYNASC), pages 152--159, Sept. 2012.
[5]
S. Barman. Aster: Automatic abstract syntax. PhD thesis, University of Texas at Austin, May 2009.
[6]
D. Beyer. Relational Programming with CrocoPat. In Proceedings of the 28th International Conference on Software Engineering, ICSE '06, pages 807--810, New York, NY, USA, 2006. ACM.
[7]
M. Bravenboer, K. T. Kalleberg, R. Vermaas, and E. Visser. Stratego/XT 0.17. A language and toolset for program transformation. Science of Computer Programming, 72(1âĂŞ2):52--70, June 2008.
[8]
F. Catthoor, K. Danckaert, S. Wuytack, and N. Dutt. Code transformations for data transfer and storage exploration preprocessing in multimedia processors. IEEE Design Test of Computers, 18(3):70--82, May 2001.
[9]
T. Cohen, J. Y. Gil, and I. Maman. JTL: The Java Tools Language. In Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-oriented Programming Systems, Languages, and Applications, OOPSLA '06, pages 89--108, New York, NY, USA, 2006. ACM.
[10]
J. R. Cordy. The TXL source transformation language. Science of Computer Programming, 61(3):190--210, Aug. 2006.
[11]
R. F. Crew. ASTLOG: A Language for Examining Abstract Syntax Trees. In Proceedings of the Conference on Domain-Specific Languages on Conference on Domain-Specific Languages (DSL), 1997, DSL'97, pages 18--18, Berkeley, CA, USA, 1997. USENIX Association.
[12]
O. de Moor, M. Verbaere, and E. Hajiyev. Keynote Address: QL for Source Code Analysis. In Seventh IEEE International Working Conference on Source Code Analysis and Manipulation, 2007. SCAM 2007, pages 3--16, Sept. 2007.
[13]
C. De Roover, C. Noguera, A. Kellens, and V. Jonckers. The SOUL Tool Suite for Querying Programs in Symbiosis with Eclipse. In Proceedings of the 9th International Conference on Principles and Practice of Programming in Java, PPPJ '11, pages 71--80, New York, NY, USA, 2011. ACM.
[14]
C. De Roover and R. Stevens. Building development tools interactively using the EKEKO meta-programming library. In 2014 Software Evolution Week - IEEE Conference on Software Maintenance, Reengineering and Reverse Engineering (CSMR-WCRE), pages 429--433, Feb. 2014.
[15]
G. Dimitroulakos, C. Lezos, and K. Masselos. MEMSCOPT: A source-to-source compiler for dynamic code analysis and loop transformations. In Proceedings of the 2012 Conference on Design and Architectures for Signal and Image Processing (DASIP), pages 385--386, Karlsruhe, Germany, Oct. 2012.
[16]
A. Floc'h, T. Yuki, A. El-Moussawi, A. Morvan, K. Martin, M. Naullet, M. Alle, L. L'Hours, N. Simon, S. Derrien, F. Charot, C. Wolinski, and O. Sentieys. GeCoS: A framework for prototyping custom hardware design flows. In 2013 IEEE 13th International Working Conference on Source Code Analysis and Manipulation (SCAM), volume 0, pages 100--105, Los Alamitos, CA, USA, 2013. IEEE Computer Society.
[17]
M. Forsberg. Three Tools for Language Processing: BNF Converter, Functional Morphology, and Extract. Ph.D. Thesis, Chalmers University of Technology and Goteborg University, Goteborg, Sweden, 2007.
[18]
M. Fowler. Domain-Specific Languages. Addison-Wesley Professional, Upper Saddle River, NJ, 1 edition edition, Oct. 2010.
[19]
E. Gagnon and L. Hendren. SableCC, an object-oriented compiler framework. In Technology of Object-Oriented Languages, 1998. TOOLS 26. Proceedings, pages 140--154, Aug. 1998.
[20]
S. Gunther. Development of Internal Domain-specific Languages: Design Principles and Design Patterns. In Proceedings of the 18th Conference on Pattern Languages of Programs, PLoP '11, pages 1:1--1:25, New York, NY, USA, 2011. ACM.
[21]
E. Hajiyev, M. Verbaere, and O. d. Moor. codeQuest: Scalable Source Code Queries with Datalog. In ECOOP 2006 âĂŞ Object-Oriented Programming, number 4067, pages 2--27. Springer Berlin Heidelberg, 2006.
[22]
L. C. Kats and E. Visser. The Spoofax Language Workbench: Rules for Declarative Specification of Languages and IDEs. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA '10, pages 444--463, New York, NY, USA, 2010. ACM.
[23]
P. Klint, T. van der Storm, and J. Vinju. RASCAL: A Domain Specific Language for Source Code Analysis and Manipulation. In Ninth IEEE International Working Conference on Source Code Analysis and Manipulation, 2009. SCAM '09, pages 168--177, Sept. 2009.
[24]
S.-I. Lee, T. A. Johnson, and R. Eigenmann. Cetus âĂŞ An Extensible Compiler Infrastructure for Source-to-Source Transformation. In Languages and Compilers for Parallel Computing, number 2958, pages 539--553. Springer Berlin Heidelberg, 2004.
[25]
C. Lezos, G. Dimitroulakos, A. Freskou, and K. Masselos. Dynamic source code analysis for memory hierarchy optimization in multimedia applications. In Proceedings of the 2013 Conference on Design and Architectures for Signal and Image Processing (DASIP), pages 343--344, Cagliari, Italy, Oct. 2013.
[26]
C. Lezos, G. Dimitroulakos, and K. Masselos. Reuse distance analysis for locality optimization in loop-dominated applications. In Proceedings of the 2015 Design, Automation & Test in Europe Conference & Exhibition (DATE), pages 1237--1240, Grenoble, France, Mar. 2015.
[27]
B. C. Lopes and R. Auler. Getting Started with LLVM Core Libraries. Packt Publishing, Aug. 2014.
[28]
P. B. Mann. A Translational BNF Grammar Notation (TBNF). SIGPLAN Not., 41(4):16--23, Apr. 2006.
[29]
M. Martin, B. Livshits, and M. S. Lam. Finding Application Errors and Security Flaws Using PQL: A Program Query Language. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications, OOPSLA '05, pages 365--383, New York, NY, USA, 2005. ACM.
[30]
G. C. Necula, S. McPeak, S. P. Rahul, and W. Weimer. CIL: Intermediate Language and Tools for Analysis and Transformation of C Programs. In Compiler Construction, number 2304, pages 213--228. Springer Berlin Heidelberg, 2002.
[31]
K. Ng, M. Warren, P. Golde, and A. Hejlsberg. The Roslyn Project: Exposing the C# and VB compiler's code analysis. White Paper, Microsoft Corporation, Sept. 2012.
[32]
T. Parr. The Definitive ANTLR 4 Reference. Pragmatic Bookshelf, Dallas, Texas, second edition edition, Jan. 2013.
[33]
S. H.-e. Peng. UTDSP: A VLIW Programmable DSP Processor. Master Thesis, University of Toronto, Toronto, Canada, 1999.
[34]
J. F. Power and B. A. Malloy. A metrics suite for grammar-based software. Journal of Software Maintenance and Evolution: Research and Practice, 16(6):405--426, Nov. 2004.
[35]
D. Quinlan. Rose: compiler support for object-oriented frameworks. Parallel Processing Letters, 10(02n03):215--226, June 2000.
[36]
P. Rademaker. Binary relational querying for structural source code analysis. Master Thesis, Universiteit van Utrecht, Utrecht, the Netherlands, 2008.
[37]
T. Stripf, O. Oey, T. Bruckschloegl, J. Becker, G. Rauwerda, K. Sunesen, G. Goulas, P. Alefragis, N. S. Voros, S. Derrien, O. Sentieys, N. Kavvadias, G. Dimitroulakos, K. Masselos, D. Kritharidis, N. Mitas, and T. Perschke. Compiling Scilab to high performance embedded multicore systems. Microprocessors and Microsystems, 37(8, Part C):1033--1049, Nov. 2013.
[38]
R.-G. Urma and A. Mycroft. Programming Language Evolution via Source Code Query Languages. Tucson, AZ, USA, Oct. 2012.
[39]
M. G. J. van den Brand, A. van Deursen, J. Heering, H. A. d. Jong, M. d. Jonge, T. Kuipers, P. Klint, L. Moonen, P. A. Olivier, J. Scheerder, J. J. Vinju, E. Visser, and J. Visser. The Asf+Sdf Meta-environment: A Component-Based Language Development Environment. In Compiler Construction, number 2027, pages 365--370. Springer Berlin Heidelberg, 2001.
[40]
K. D. Volder. JQuery: A Generic Code Browser with a Declarative Configuration Language. In Practical Aspects of Declarative Languages, number 3819, pages 88--102. Springer Berlin Heidelberg, 2005.
[41]
D. S. Wile. Abstract Syntax from Concrete Syntax. In Proceedings of the 19th International Conference on Software Engineering, ICSE '97, pages 472--480, New York, NY, USA, 1997. ACM.
[42]
R. P. Wilson, R. S. French, C. S. Wilson, S. P. Amarasinghe, J. M. Anderson, S. W. K. Tjiang, S.-W. Liao, C.-W. Tseng, M. W. Hall, M. S. Lam, and J. L. Hennessy. SUIF: An Infrastructure for Research on Parallelizing and Optimizing Compilers. SIGPLAN Not., 29(12):31--37, Dec. 1994.

Cited By

View all
  1. Automatic Generation of Code Analysis Tools: The CastQL Approach

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Other conferences
    RWDSL '16: Proceedings of the 1st International Workshop on Real World Domain Specific Languages
    March 2016
    46 pages
    ISBN:9781450340519
    DOI:10.1145/2889420
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 12 March 2016

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Domain specific languages
    2. code query languages
    3. compiler generators
    4. source code analysis

    Qualifiers

    • Research-article
    • Research
    • Refereed limited

    Conference

    RWDSL '16

    Acceptance Rates

    Overall Acceptance Rate 7 of 9 submissions, 78%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)0
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 06 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media