Name Date Size

..25-Oct-20244 KiB

.gitignoreH A D25-Oct-2024425

allocate.cH A D25-Oct-20244.7 KiB

allocate.hH A D25-Oct-20242.7 KiB

ast-inspect.cH A D25-Oct-20246.7 KiB

ast-inspect.hH A D25-Oct-2024330

ast-model.cH A D25-Oct-202414.4 KiB

ast-model.hH A D25-Oct-20242.2 KiB

ast-view.cH A D25-Oct-20241.1 KiB

ast-view.hH A D25-Oct-202495

bitmap.hH A D25-Oct-20241.4 KiB

bits.hH A D25-Oct-20241.4 KiB

builtin.cH A D25-Oct-202430 KiB

builtin.hH A D25-Oct-2024353

c2xml.cH A D25-Oct-20247.7 KiB

cgccH A D25-Oct-202410.5 KiB

cgcc.1H A D25-Oct-20241 KiB

char.cH A D25-Oct-20243.3 KiB

char.hH A D25-Oct-2024148

compat/H25-Oct-20244 KiB

compat-bsd.cH A D25-Oct-20241.1 KiB

compat-cygwin.cH A D25-Oct-20241.7 KiB

compat-linux.cH A D25-Oct-2024119

compat-mingw.cH A D25-Oct-20241.6 KiB

compat-solaris.cH A D25-Oct-202426

compat.hH A D25-Oct-2024685

compile-i386.cH A D25-Oct-202454.8 KiB

compile.cH A D25-Oct-20242.4 KiB

compile.hH A D25-Oct-2024199

cse.cH A D25-Oct-20248.1 KiB

cse.hH A D25-Oct-2024176

ctags.cH A D25-Oct-20245.6 KiB

dissect.cH A D25-Oct-202415.2 KiB

dissect.hH A D25-Oct-2024759

Documentation/H25-Oct-20244 KiB

dominate.cH A D25-Oct-20243.4 KiB

dominate.hH A D25-Oct-2024258

evaluate.cH A D25-Oct-202498 KiB

evaluate.hH A D25-Oct-2024973

example.cH A D25-Oct-202444.1 KiB

expand.cH A D25-Oct-202432.6 KiB

expand.hH A D25-Oct-20241.5 KiB

expression.cH A D25-Oct-202426 KiB

expression.hH A D25-Oct-20248.9 KiB

FAQH A D25-Oct-20243.3 KiB

flow.cH A D25-Oct-202423.3 KiB

flow.hH A D25-Oct-20241.5 KiB

flowgraph.cH A D25-Oct-20244.8 KiB

flowgraph.hH A D25-Oct-2024842

gcc-attr-list.hH A D25-Oct-20244.4 KiB

gdbhelpersH A D25-Oct-20245.1 KiB

graph.cH A D25-Oct-20245.7 KiB

gvpr/H25-Oct-20244 KiB

ident-list.hH A D25-Oct-20242.2 KiB

inline.cH A D25-Oct-202415.5 KiB

ir.cH A D25-Oct-20244 KiB

ir.hH A D25-Oct-2024101

lib.cH A D25-Oct-202411.4 KiB

lib.hH A D25-Oct-20247 KiB

LICENSEH A D25-Oct-20241.5 KiB

linearize.cH A D25-Oct-202466.8 KiB

linearize.hH A D25-Oct-20248.7 KiB

liveness.cH A D25-Oct-20247.1 KiB

liveness.hH A D25-Oct-2024227

machine.hH A D25-Oct-20242.9 KiB

MakefileH A D25-Oct-20248.1 KiB

memops.cH A D25-Oct-20246.7 KiB

obfuscate.cH A D25-Oct-20242.2 KiB

opcode.cH A D25-Oct-20241.5 KiB

opcode.defH A D25-Oct-20246.7 KiB

opcode.hH A D25-Oct-20241 KiB

optimize.cH A D25-Oct-20242.5 KiB

optimize.hH A D25-Oct-2024122

options.cH A D25-Oct-202424 KiB

options.hH A D25-Oct-20243.4 KiB

parse.cH A D25-Oct-202483.6 KiB

parse.dtdH A D25-Oct-20241.6 KiB

parse.hH A D25-Oct-20244.4 KiB

pre-process.cH A D25-Oct-202455.3 KiB

predefine.cH A D25-Oct-20249.2 KiB

ptrlist.cH A D25-Oct-202411.2 KiB

ptrlist.hH A D25-Oct-20249.5 KiB

ptrmap.cH A D25-Oct-20242.6 KiB

ptrmap.hH A D25-Oct-2024865

READMEH A D25-Oct-20242.9 KiB

scheck.cH A D25-Oct-20249.8 KiB

scope.cH A D25-Oct-20244.1 KiB

scope.hH A D25-Oct-20242.1 KiB

semind.1H A D25-Oct-20242.9 KiB

semind.cH A D25-Oct-202428.2 KiB

show-parse.cH A D25-Oct-202428.1 KiB

simplify.cH A D25-Oct-202469.8 KiB

simplify.hH A D25-Oct-2024192

sort.cH A D25-Oct-20245.6 KiB

sparse-llvm-disH A D25-Oct-2024271

sparse-llvm.cH A D25-Oct-202431.1 KiB

sparse.1H A D25-Oct-202419.6 KiB

sparse.cH A D25-Oct-20248 KiB

sparsecH A D25-Oct-2024958

sparseiH A D25-Oct-2024404

ssa.cH A D25-Oct-20248.6 KiB

ssa.hH A D25-Oct-202498

stats.cH A D25-Oct-20241.7 KiB

storage.cH A D25-Oct-20246.6 KiB

storage.hH A D25-Oct-20241.7 KiB

symbol.cH A D25-Oct-202427.7 KiB

symbol.hH A D25-Oct-202416.4 KiB

target-alpha.cH A D25-Oct-2024986

target-arm.cH A D25-Oct-20241.1 KiB

target-arm64.cH A D25-Oct-2024847

target-bfin.cH A D25-Oct-2024563

target-default.cH A D25-Oct-2024190

target-h8300.cH A D25-Oct-2024663

target-m68k.cH A D25-Oct-2024572

target-microblaze.cH A D25-Oct-2024697

target-mips.cH A D25-Oct-20241.2 KiB

target-nds32.cH A D25-Oct-2024640

target-nios2.cH A D25-Oct-20241.1 KiB

target-openrisc.cH A D25-Oct-2024582

target-ppc.cH A D25-Oct-20241.6 KiB

target-riscv.cH A D25-Oct-20243.8 KiB

target-s390.cH A D25-Oct-20241.3 KiB

target-sh.cH A D25-Oct-2024666

target-sparc.cH A D25-Oct-20241.6 KiB

target-x86.cH A D25-Oct-20243.4 KiB

target-xtensa.cH A D25-Oct-2024583

target.cH A D25-Oct-20246.5 KiB

target.hH A D25-Oct-20244.1 KiB

test-dissect.cH A D25-Oct-20242.7 KiB

test-inspect.cH A D25-Oct-2024899

test-lexing.cH A D25-Oct-20241.7 KiB

test-linearize.cH A D25-Oct-20242 KiB

test-parsing.cH A D25-Oct-20242.4 KiB

test-show-type.cH A D25-Oct-2024512

test-sort.cH A D25-Oct-2024852

test-unssa.cH A D25-Oct-20241.7 KiB

token.hH A D25-Oct-20246.5 KiB

tokenize.cH A D25-Oct-202423.2 KiB

unssa.cH A D25-Oct-20243.5 KiB

utils.cH A D25-Oct-2024956

utils.hH A D25-Oct-20241.3 KiB

validation/H25-Oct-202420 KiB

version.cH A D25-Oct-202484

README

1
2  sparse (spärs), adj,., spars-er, spars-est.
3	1. thinly scattered or distributed; "a sparse population"
4	2. thin; not thick or dense: "sparse hair"
5	3. scanty; meager.
6	4. semantic parse
7  	[ from Latin: spars(us) scattered, past participle of
8	  spargere 'to sparge' ]
9
10	Antonym: abundant
11
12Sparse is a semantic parser of source files: it's neither a compiler
13(although it could be used as a front-end for one) nor is it a
14preprocessor (although it contains as a part of it a preprocessing
15phase). 
16
17It is meant to be a small - and simple - library.  Scanty and meager,
18and partly because of that easy to use.  It has one mission in life:
19create a semantic parse tree for some arbitrary user for further
20analysis.  It's not a tokenizer, nor is it some generic context-free
21parser.  In fact, context (semantics) is what it's all about - figuring
22out not just what the grouping of tokens are, but what the _types_ are
23that the grouping implies.
24
25And no, it doesn't use lex and yacc (or flex and bison).  In my personal
26opinion, the result of using lex/yacc tends to end up just having to
27fight the assumptions the tools make. 
28
29The parsing is done in five phases:
30
31 - full-file tokenization
32 - pre-processing (which can cause another tokenization phase of another
33   file)
34 - semantic parsing.
35 - lazy type evaluation
36 - inline function expansion and tree simplification
37
38Note the "full file" part. Partly for efficiency, but mostly for ease of
39use, there are no "partial results". The library completely parses one
40whole source file, and builds up the _complete_ parse tree in memory.
41
42Also note the "lazy" in the type evaluation.  The semantic parsing
43itself will know which symbols are typedefines (required for parsing C
44correctly), but it will not have calculated what the details of the
45different types are.  That will be done only on demand, as the back-end
46requires the information. 
47
48This means that a user of the library will literally just need to do
49
50  struct string_list *filelist = NULL;
51  char *file;
52
53  action(sparse_initialize(argc, argv, filelist));
54
55  FOR_EACH_PTR(filelist, file) {
56    action(sparse(file));
57  } END_FOR_EACH_PTR(file);
58
59and he is now done - having a full C parse of the file he opened.  The
60library doesn't need any more setup, and once done does not impose any
61more requirements.  The user is free to do whatever he wants with the
62parse tree that got built up, and needs not worry about the library ever
63again.  There is no extra state, there are no parser callbacks, there is
64only the parse tree that is described by the header files. The action
65funtion takes a pointer to a symbol_list and does whatever it likes with it.
66
67The library also contains (as an example user) a few clients that do the
68preprocessing, parsing and type evaluation and just print out the
69results.  These clients were done to verify and debug the library, and
70also as trivial examples of what you can do with the parse tree once it
71is formed, so that users can see how the tree is organized. 
72