Welcome to ABC, the ANTLR-Based C front-end. ABC is a Java
program for parsing and manipulating programs written in C and
possibly some languages extending C, such as CIVL-C. It can be used to
perform a number of tasks, including the following:
- preprocess the source file(s)
- parse the preprocessed source to form an Abstract Syntax Tree
representation of a translation unit
- analyze an AST to determine the type of every expression, the
entity associated to every identifier, the scope of every node, and
so on
- merge multiple ASTs into one large AST
- transform ASTs, by, for example, removing expressions with
side-effects, renaming entities, pruning unreachable code, etc.
In addition, it provides a framework for developing your own analyses
or transformations on ASTs.
There is a simple command-line interface for ABC (see {@link
dev.civl.abc.ABC ABC}), but most users will want to use ABC
through its API. To use the API, it is helpful to have some
understanding of the modular structure of ABC. The ABC source code is
decomposed into modules, each with a well-defined interface and set of
responsibilities. Some of these modules are decomposed further into
sub-modules. The top-level modules are:
- util
- responsibilities: simple general-purpose utility classes
that do not use other parts of ABC
- uses: nothing
- interface: {@link dev.civl.abc.util.IF}
- entry point: none
- config
- responsibilities: representation of configuration
parameters for ABC
- uses: nothing
- interface: {@link dev.civl.abc.config.IF}
- entry point: {@link
dev.civl.abc.config.IF.Configurations Configurations}
- token
- responsibilities: representing tokens; keeping track of the
origin and history of each token through macro expansion and
inclusion; representing characters and strings
- uses: util
- interface: {@link dev.civl.abc.token.IF}
- entry point: {@link dev.civl.abc.token.IF.Tokens
Tokens}
- front
- responsibilities: preprocessing and parsing a file to
produce an ANTLR tree representation of a translation unit
- uses: util, config, token
- interface: {@link dev.civl.abc.front.IF},
- entry point:
- submodules
- preproc
- responsibilities: preprocessing a file to generate a
post-preprocessor token stream
- uses: util, config, token
- interface: {@link
dev.civl.abc.front.c.preproc.IF}, {@link
dev.civl.abc.front.fortran.preproc.IF}
- entry point: {@link
dev.civl.abc.front.c.preproc.IF.Preprocess Preprocess},
{@link dev.civl.abc.front.fortran.preproc.IF.Preprocess
Preprocess}
- parse
- responsibilities: parsing a token stream to produce an
ANTLR tree representation of a translation unit
- uses: util, config, token
- interface: {@link
dev.civl.abc.front.c.parse.IF}, {@link
dev.civl.abc.front.fortran.parse.IF}
- entry point: {@link
dev.civl.abc.front.c.parse.IF.Parse Parse}, {@link
dev.civl.abc.front.fortran.parse.IF.Parse Parse}
- ptree
- ast
- responsibilities: representation and manipulation of an
Abstract Syntax Tree and associated entities
- uses: util, token
- interface: {@link dev.civl.abc.ast.IF}
- entry point: {@link dev.civl.abc.ast.IF.ASTs ASTs}
- submodules
- value
- responsibilities: representation of concrete value,
such as characters, integers, floating point values
- interface: {@link dev.civl.abc.ast.value.IF}
- entry point: {@link
dev.civl.abc.ast.value.IF.Values Values}
- type
- responsibilities: representation of types
- interface: {@link dev.civl.abc.ast.type.IF}
- entry point: {@link
dev.civl.abc.ast.type.IF.Types Types}
- entity
- responsibilities: representation of abstract program
entities which can be named by an identifier, including
variables, functions, labels, scopes, structures, unions,
enumerations, enumerators, and typedefs
- interface: {@link dev.civl.abc.ast.entity.IF}
- entry point: {@link
dev.civl.abc.ast.entity.IF.Entities Entities}
- conversion
- responsibilities: representation of C's implicit
conversions, such as the conversion of an array to a pointer to
the first element of the array, and so on
- interface: {@link
dev.civl.abc.ast.conversion.IF}
- entry point: {@link
dev.civl.abc.ast.conversion.IF.Conversions Conversions}
- node
- responsibilities: representation of AST nodes
- interface: {@link dev.civl.abc.ast.node.IF}
- entry point: {@link
dev.civl.abc.ast.node.IF.Nodes Nodes}
- astgen
- responsibilities: translation of ANTLR tree to AST
- uses: util, token, front,
ast
- interface: {@link dev.civl.abc.astgen.IF}, {@link
dev.civl.abc.astgen.c.IF}, {@link
dev.civl.abc.astgen.fortran.IF}
- entry point: {@link
dev.civl.abc.astgen.IF.ASTGenerator}
- analysis
- responsibilities: analyzing AST, creation of entities,
resolution of all identifiers, determination of all scopes, types,
and entities
- uses: config, token, ast
- interface: {@link dev.civl.abc.analysis.IF}
- entry point: {@link
dev.civl.abc.analysis.IF.Analysis Analysis}
- transform
- responsibilities: transformations of an AST
- uses: token, ast
- interface: {@link dev.civl.abc.transform.IF}
- entry point: {@link
dev.civl.abc.transform.IF.Transform Transform}
- program
- responsibilities: mutable representation of a program
- uses: token, ast, analysis,
transform
- interface: {@link dev.civl.abc.program.IF}
- entry point: {@link
dev.civl.abc.program.IF.Programs Programs}
- main
- responsibilities: command line interface, Activator class
for marshaling of tools in tool chain
- uses: util, token, front,
ast, astgen, analysis,
transform, program
- interface: {@link dev.civl.abc}
- entry point: {@link dev.civl.abc.ABC ABC}