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

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.