• Home
Name Date Size #Lines LOC

..--

Documentation/12-May-2024-5,0864,174

compat/12-May-2024-10078

gvpr/12-May-2024-290242

validation/12-May-2024-26,06011,619

.gitignoreD12-May-2024425 5042

FAQD12-May-20243.3 KiB7556

LICENSED12-May-20241.5 KiB3526

MakefileD12-May-20248.1 KiB312244

READMED12-May-20242.9 KiB7256

allocate.cD12-May-20244.7 KiB157104

allocate.hD12-May-20242.7 KiB9885

ast-inspect.cD12-May-20246.7 KiB221194

ast-inspect.hD12-May-2024330 1810

ast-model.cD12-May-202414.4 KiB470240

ast-model.hD12-May-20242.2 KiB9155

ast-view.cD12-May-20241.1 KiB5035

ast-view.hD12-May-202495 83

bitmap.hD12-May-20241.4 KiB5242

bits.hD12-May-20241.4 KiB7449

builtin.cD12-May-202430 KiB840663

builtin.hD12-May-2024353 2014

c2xml.cD12-May-20247.7 KiB335248

cgccD12-May-202410.5 KiB358293

cgcc.1D12-May-20241 KiB3836

char.cD12-May-20243.3 KiB152145

char.hD12-May-2024148 32

compat-bsd.cD12-May-20241.1 KiB251

compat-cygwin.cD12-May-20241.7 KiB5727

compat-linux.cD12-May-2024119 85

compat-mingw.cD12-May-20241.6 KiB5424

compat-solaris.cD12-May-202426 21

compat.hD12-May-2024685 277

compile-i386.cD12-May-202454.8 KiB2,3951,822

compile.cD12-May-20242.4 KiB8748

compile.hD12-May-2024199 117

cse.cD12-May-20248.1 KiB373273

cse.hD12-May-2024176 127

ctags.cD12-May-20245.6 KiB228176

dissect.cD12-May-202415.2 KiB661510

dissect.hD12-May-2024759 3927

dominate.cD12-May-20243.4 KiB154115

dominate.hD12-May-2024258 147

evaluate.cD12-May-202498 KiB3,9633,135

evaluate.hD12-May-2024973 3612

example.cD12-May-202444.1 KiB1,9601,548

expand.cD12-May-202432.6 KiB1,4631,140

expand.hD12-May-20241.5 KiB357

expression.cD12-May-202426 KiB970802

expression.hD12-May-20248.9 KiB344203

flow.cD12-May-202423.3 KiB1,043778

flow.hD12-May-20241.5 KiB5036

flowgraph.cD12-May-20244.8 KiB224155

flowgraph.hD12-May-2024842 349

gcc-attr-list.hD12-May-20244.4 KiB211210

gdbhelpersD12-May-20245.1 KiB290236

graph.cD12-May-20245.7 KiB207138

ident-list.hD12-May-20242.2 KiB9063

inline.cD12-May-202415.5 KiB585477

ir.cD12-May-20244 KiB208165

ir.hD12-May-2024101 95

lib.cD12-May-202411.4 KiB492334

lib.hD12-May-20247 KiB251180

linearize.cD12-May-202466.8 KiB2,6732,202

linearize.hD12-May-20248.7 KiB358298

liveness.cD12-May-20247.1 KiB331255

liveness.hD12-May-2024227 127

machine.hD12-May-20242.9 KiB134119

memops.cD12-May-20246.7 KiB296240

obfuscate.cD12-May-20242.2 KiB7742

opcode.cD12-May-20241.5 KiB4016

opcode.defD12-May-20246.7 KiB116101

opcode.hD12-May-20241 KiB5344

optimize.cD12-May-20242.5 KiB13584

optimize.hD12-May-2024122 105

options.cD12-May-202424 KiB1,046875

options.hD12-May-20243.4 KiB146132

parse.cD12-May-202483.6 KiB3,0672,527

parse.dtdD12-May-20241.6 KiB5245

parse.hD12-May-20244.4 KiB146106

pre-process.cD12-May-202455.3 KiB2,3561,894

predefine.cD12-May-20249.2 KiB286242

ptrlist.cD12-May-202411.2 KiB511321

ptrlist.hD12-May-20249.5 KiB314234

ptrmap.cD12-May-20242.6 KiB11072

ptrmap.hD12-May-2024865 2923

scheck.cD12-May-20249.8 KiB363304

scope.cD12-May-20244.1 KiB184126

scope.hD12-May-20242.1 KiB6832

semind.1D12-May-20242.9 KiB152150

semind.cD12-May-202428.2 KiB1,181964

show-parse.cD12-May-202428.1 KiB1,205982

simplify.cD12-May-202469.8 KiB2,8212,255

simplify.hD12-May-2024192 116

sort.cD12-May-20245.6 KiB291228

sparse-llvm-disD12-May-2024271 168

sparse-llvm.cD12-May-202431.1 KiB1,3611,107

sparse.1D12-May-202419.6 KiB589508

sparse.cD12-May-20248 KiB338263

sparsecD12-May-2024958 6347

sparseiD12-May-2024404 3224

ssa.cD12-May-20248.6 KiB402332

ssa.hD12-May-202498 95

stats.cD12-May-20241.7 KiB6350

storage.cD12-May-20246.6 KiB278220

storage.hD12-May-20241.7 KiB8059

symbol.cD12-May-202427.7 KiB1,006788

symbol.hD12-May-202416.4 KiB593462

target-alpha.cD12-May-2024986 3427

target-arm.cD12-May-20241.1 KiB5846

target-arm64.cD12-May-2024847 4534

target-bfin.cD12-May-2024563 2721

target-default.cD12-May-2024190 129

target-h8300.cD12-May-2024663 3527

target-m68k.cD12-May-2024572 3325

target-microblaze.cD12-May-2024697 3527

target-mips.cD12-May-20241.2 KiB6448

target-nds32.cD12-May-2024640 3425

target-nios2.cD12-May-20241.1 KiB4839

target-openrisc.cD12-May-2024582 3224

target-ppc.cD12-May-20241.6 KiB8568

target-riscv.cD12-May-20243.8 KiB163141

target-s390.cD12-May-20241.3 KiB7457

target-sh.cD12-May-2024666 3728

target-sparc.cD12-May-20241.6 KiB8865

target-x86.cD12-May-20243.4 KiB171142

target-xtensa.cD12-May-2024583 3224

target.cD12-May-20246.5 KiB278228

target.hD12-May-20244.1 KiB163119

test-dissect.cD12-May-20242.7 KiB128100

test-inspect.cD12-May-2024899 4638

test-lexing.cD12-May-20241.7 KiB5021

test-linearize.cD12-May-20242 KiB7038

test-parsing.cD12-May-20242.4 KiB9250

test-show-type.cD12-May-2024512 2921

test-sort.cD12-May-2024852 4738

test-unssa.cD12-May-20241.7 KiB9072

token.hD12-May-20246.5 KiB253180

tokenize.cD12-May-202423.2 KiB1,037853

unssa.cD12-May-20243.5 KiB14379

utils.cD12-May-2024956 6550

utils.hD12-May-20241.3 KiB4810

version.cD12-May-202484 53

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