mooigraph 8ee3407a65 sparse update 4 years ago
..
Documentation 8c87a7d591 initial 4 years ago
compat 8c87a7d591 initial 4 years ago
gvpr 8c87a7d591 initial 4 years ago
validation 8c87a7d591 initial 4 years ago
.gitignore 8c87a7d591 initial 4 years ago
FAQ 8c87a7d591 initial 4 years ago
LICENSE 8c87a7d591 initial 4 years ago
Makefile 8c87a7d591 initial 4 years ago
README 8c87a7d591 initial 4 years ago
allocate.c 8c87a7d591 initial 4 years ago
allocate.h 8c87a7d591 initial 4 years ago
ast-inspect.c 8c87a7d591 initial 4 years ago
ast-inspect.h 8c87a7d591 initial 4 years ago
ast-model.c 8c87a7d591 initial 4 years ago
ast-model.h 8c87a7d591 initial 4 years ago
ast-view.c 8c87a7d591 initial 4 years ago
ast-view.h 8c87a7d591 initial 4 years ago
bitmap.h 8c87a7d591 initial 4 years ago
bits.h 8c87a7d591 initial 4 years ago
builtin.c 8c87a7d591 initial 4 years ago
builtin.h 8c87a7d591 initial 4 years ago
c2xml.c 8c87a7d591 initial 4 years ago
cgcc 8c87a7d591 initial 4 years ago
cgcc.1 8c87a7d591 initial 4 years ago
char.c 8c87a7d591 initial 4 years ago
char.h 8c87a7d591 initial 4 years ago
compat-bsd.c 8c87a7d591 initial 4 years ago
compat-cygwin.c 8c87a7d591 initial 4 years ago
compat-linux.c 8c87a7d591 initial 4 years ago
compat-mingw.c 8c87a7d591 initial 4 years ago
compat-solaris.c 8c87a7d591 initial 4 years ago
compat.h 8c87a7d591 initial 4 years ago
compile-i386.c 8c87a7d591 initial 4 years ago
compile.c 8c87a7d591 initial 4 years ago
compile.h 8c87a7d591 initial 4 years ago
cse.c 8c87a7d591 initial 4 years ago
cse.h 8c87a7d591 initial 4 years ago
ctags.c 8c87a7d591 initial 4 years ago
dissect.c 8c87a7d591 initial 4 years ago
dissect.h 8c87a7d591 initial 4 years ago
dominate.c 8c87a7d591 initial 4 years ago
dominate.h 8c87a7d591 initial 4 years ago
evaluate.c 8c87a7d591 initial 4 years ago
evaluate.h 8c87a7d591 initial 4 years ago
example.c 8c87a7d591 initial 4 years ago
expand.c 8c87a7d591 initial 4 years ago
expand.h 8c87a7d591 initial 4 years ago
expression.c 8c87a7d591 initial 4 years ago
expression.h 8c87a7d591 initial 4 years ago
flow.c 8c87a7d591 initial 4 years ago
flow.h 8c87a7d591 initial 4 years ago
flowgraph.c 8c87a7d591 initial 4 years ago
flowgraph.h 8c87a7d591 initial 4 years ago
gcc-attr-list.h 8c87a7d591 initial 4 years ago
gdbhelpers 8c87a7d591 initial 4 years ago
graph.c 8c87a7d591 initial 4 years ago
ident-list.h 8c87a7d591 initial 4 years ago
inline.c 8c87a7d591 initial 4 years ago
ir.c 8c87a7d591 initial 4 years ago
ir.h 8c87a7d591 initial 4 years ago
lib.c 8c87a7d591 initial 4 years ago
lib.h 8c87a7d591 initial 4 years ago
linearize.c 0503fa5e33 sparse bug 4 years ago
linearize.h 8c87a7d591 initial 4 years ago
liveness.c 8c87a7d591 initial 4 years ago
liveness.h 8c87a7d591 initial 4 years ago
machine.h 8c87a7d591 initial 4 years ago
memops.c 8c87a7d591 initial 4 years ago
obfuscate.c 8c87a7d591 initial 4 years ago
opcode.c 8c87a7d591 initial 4 years ago
opcode.def 8c87a7d591 initial 4 years ago
opcode.h 8c87a7d591 initial 4 years ago
optimize.c 8c87a7d591 initial 4 years ago
optimize.h 8c87a7d591 initial 4 years ago
options.c 8c87a7d591 initial 4 years ago
options.h 8c87a7d591 initial 4 years ago
parse.c 8c87a7d591 initial 4 years ago
parse.dtd 8c87a7d591 initial 4 years ago
parse.h 8c87a7d591 initial 4 years ago
pre-process.c 8c87a7d591 initial 4 years ago
predefine.c 8c87a7d591 initial 4 years ago
ptrlist.c 8c87a7d591 initial 4 years ago
ptrlist.h 8c87a7d591 initial 4 years ago
ptrmap.c 8c87a7d591 initial 4 years ago
ptrmap.h 8c87a7d591 initial 4 years ago
scope.c 8c87a7d591 initial 4 years ago
scope.h 8c87a7d591 initial 4 years ago
semind.1 8c87a7d591 initial 4 years ago
semind.c 8c87a7d591 initial 4 years ago
show-parse.c 8c87a7d591 initial 4 years ago
simplify.c 8c87a7d591 initial 4 years ago
sort.c 8c87a7d591 initial 4 years ago
sparse-llvm-dis 8c87a7d591 initial 4 years ago
sparse-llvm.c 8c87a7d591 initial 4 years ago
sparse.1 8c87a7d591 initial 4 years ago
sparse.c 8c87a7d591 initial 4 years ago
sparsec 8c87a7d591 initial 4 years ago
sparsei 8c87a7d591 initial 4 years ago
ssa.c 8c87a7d591 initial 4 years ago
ssa.h 8c87a7d591 initial 4 years ago
sset.c 8c87a7d591 initial 4 years ago
sset.h 8c87a7d591 initial 4 years ago
stats.c 8c87a7d591 initial 4 years ago
storage.c 8c87a7d591 initial 4 years ago
storage.h 8c87a7d591 initial 4 years ago
symbol.c 8c87a7d591 initial 4 years ago
symbol.h 8ee3407a65 sparse update 4 years ago
target-alpha.c 8c87a7d591 initial 4 years ago
target-arm.c 8c87a7d591 initial 4 years ago
target-arm64.c 8c87a7d591 initial 4 years ago
target-bfin.c 8c87a7d591 initial 4 years ago
target-default.c 8c87a7d591 initial 4 years ago
target-h8300.c 8c87a7d591 initial 4 years ago
target-m68k.c 8c87a7d591 initial 4 years ago
target-microblaze.c 8c87a7d591 initial 4 years ago
target-mips.c 8c87a7d591 initial 4 years ago
target-nds32.c 8c87a7d591 initial 4 years ago
target-nios2.c 8c87a7d591 initial 4 years ago
target-openrisc.c 8c87a7d591 initial 4 years ago
target-ppc.c 8c87a7d591 initial 4 years ago
target-riscv.c 8c87a7d591 initial 4 years ago
target-s390.c 8c87a7d591 initial 4 years ago
target-sh.c 8c87a7d591 initial 4 years ago
target-sparc.c 8c87a7d591 initial 4 years ago
target-x86.c 8c87a7d591 initial 4 years ago
target-xtensa.c 8c87a7d591 initial 4 years ago
target.c 8c87a7d591 initial 4 years ago
target.h 8c87a7d591 initial 4 years ago
test-dissect.c 8c87a7d591 initial 4 years ago
test-inspect.c 8c87a7d591 initial 4 years ago
test-lexing.c 8c87a7d591 initial 4 years ago
test-linearize.c 8c87a7d591 initial 4 years ago
test-parsing.c 8c87a7d591 initial 4 years ago
test-show-type.c 8c87a7d591 initial 4 years ago
test-sort.c 8c87a7d591 initial 4 years ago
test-unssa.c 8c87a7d591 initial 4 years ago
token.h 8c87a7d591 initial 4 years ago
tokenize.c 8c87a7d591 initial 4 years ago
unssa.c 8c87a7d591 initial 4 years ago
utils.c 8c87a7d591 initial 4 years ago
utils.h 8c87a7d591 initial 4 years ago

README


sparse (spärs), adj,., spars-er, spars-est.
1. thinly scattered or distributed; "a sparse population"
2. thin; not thick or dense: "sparse hair"
3. scanty; meager.
4. semantic parse
[ from Latin: spars(us) scattered, past participle of
spargere 'to sparge' ]

Antonym: abundant

Sparse is a semantic parser of source files: it's neither a compiler
(although it could be used as a front-end for one) nor is it a
preprocessor (although it contains as a part of it a preprocessing
phase).

It is meant to be a small - and simple - library. Scanty and meager,
and partly because of that easy to use. It has one mission in life:
create a semantic parse tree for some arbitrary user for further
analysis. It's not a tokenizer, nor is it some generic context-free
parser. In fact, context (semantics) is what it's all about - figuring
out not just what the grouping of tokens are, but what the _types_ are
that the grouping implies.

And no, it doesn't use lex and yacc (or flex and bison). In my personal
opinion, the result of using lex/yacc tends to end up just having to
fight the assumptions the tools make.

The parsing is done in five phases:

- full-file tokenization
- pre-processing (which can cause another tokenization phase of another
file)
- semantic parsing.
- lazy type evaluation
- inline function expansion and tree simplification

Note the "full file" part. Partly for efficiency, but mostly for ease of
use, there are no "partial results". The library completely parses one
whole source file, and builds up the _complete_ parse tree in memory.

Also note the "lazy" in the type evaluation. The semantic parsing
itself will know which symbols are typedefines (required for parsing C
correctly), but it will not have calculated what the details of the
different types are. That will be done only on demand, as the back-end
requires the information.

This means that a user of the library will literally just need to do

struct string_list *filelist = NULL;
char *file;

action(sparse_initialize(argc, argv, filelist));

FOR_EACH_PTR(filelist, file) {
action(sparse(file));
} END_FOR_EACH_PTR(file);

and he is now done - having a full C parse of the file he opened. The
library doesn't need any more setup, and once done does not impose any
more requirements. The user is free to do whatever he wants with the
parse tree that got built up, and needs not worry about the library ever
again. There is no extra state, there are no parser callbacks, there is
only the parse tree that is described by the header files. The action
funtion takes a pointer to a symbol_list and does whatever it likes with it.

The library also contains (as an example user) a few clients that do the
preprocessing, parsing and type evaluation and just print out the
results. These clients were done to verify and debug the library, and
also as trivial examples of what you can do with the parse tree once it
is formed, so that users can see how the tree is organized.