ckit is a C front end written in SML that translates C source code (after preprocessing) into abstract syntax represented as a set of SML datatypes. It also provides facilities for extending the C language with additional syntactic constructs, which can be useful for implementing "C-like" domain-specific languages as well as C dialects. Ckit is currently used as the front end for a variety of tools for static analysis of C code and at least one domain-specific language.
Let CKIT be the directory containing the CKit code.
Run SML in directory $CKIT/ast.
Execute "CM.make();". This gives you the parser/elaborator.
On unpacking the ckit sources, you should see a src directory, a doc directory and a README file (and possibly other directories, depending on the distribution).
The src directory contains the following subdirectories:
lexer and parser, parse trees.
abstract syntax trees (Ast), type-checker, pretty-printer.
flags for controlling the parser and type-checker.
To build the system, cd to src, run SML/NJ and type
To test the parser on "test.c", type
- ParseToAst.fileToAst "test.c";
This parses and typechecks "test.c" and returns an abstract syntax tree for "test.c". Alternatively, to parse, type-check and then pretty-print "test.c", type
- ParseToAst.fileToC "test.c";
What's New in This Release:
· Reworked size and alignment mechanism to support parameterization (see src/ast/sizes[-sig].sml). A utility program (src/c-util/sizes.c) can be used to generate sizes info for a given compiler/platform combination.