CRAQL: A Composable Language for Querying Source Code

01/27/2019
by   Blake Johnson, et al.
0

This paper describes the design and implementation of CRAQL (Composable Repository Analysis and Query Language), a new query language for source code. The growth of source code mining and its applications suggest the need for a query language that can fully utilize and correlate across the unique structure and metadata of parsed source code. CRAQL is built on an underlying abstraction analogous to the underpinnings of SQL, but aimed at parsed source code. Thus, while SQL queries' inputs and outputs are sets of tuples, CRAQL queries' inputs and outputs are sets of abstract syntax trees (ASTs). This abstraction makes CRAQL queries composable (the output of one query can become the input to another) and improves the power of the language by allowing for querying of the tree structure and metadata, as well as raw text. Furthermore, the abstraction enables tree-specific language optimizations and allows CRAQL to be easily applied to any language that is parsable into ASTs. These attributes, along with a familiar syntax similar to SQL, allow complex queries to be expressed in a compact, straightforward manner. Questions such as "find the longest series of statements without any loops," "find methods that are never called," "find getters (0-parameter methods with a single statement that returns a member variable)," or "find the percentage of variables declared at the top of a block" all translate to simple, understandable queries in CRAQL. In this paper we describe the language, its features and capabilities. We compare CRAQL to other languages for querying source code and find that it has potential advantages in clarity and compactness. We discuss the features and optimizations added to support searching parse tree collections effectively and efficiently. Finally, we summarize the application of the language to millions of Java source files, the details of which are in a companion paper.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
08/06/2017

CodeSum: Translate Program Language to Natural Language

During software maintenance, programmers spend a lot of time on code com...
research
06/06/2023

DashQL – Complete Analysis Workflows with SQL

We present DashQL, a language that describes complete analysis workflows...
research
06/14/2019

SchenQL -- A Domain-Specific Query Language on Bibliographic Metadata

Information access needs to be uncomplicated, users rather use incorrect...
research
07/25/2020

Automated Query Generation for Design Pattern Mining in Source Code

Identifying which design patterns already exist in source code can help ...
research
04/06/2022

DiffSearch: A Scalable and Precise Search Engine for Code Changes

The source code of successful projects is evolving all the time, resulti...
research
09/17/2020

Extensible Data Skipping

Data skipping reduces I/O for SQL queries by skipping over irrelevant da...
research
08/20/2017

Fast Access to Columnar, Hierarchically Nested Data via Code Transformation

Big Data query systems represent data in a columnar format for fast, sel...

Please sign up or login with your details

Forgot password? Click here to reset