lucvoo / sparse Goto Github PK
View Code? Open in Web Editor NEWmirror of git://git.kernel.org/pub/scm/devel/sparse/sparse.git
License: Other
mirror of git://git.kernel.org/pub/scm/devel/sparse/sparse.git
License: Other
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.
Commit 3f5a1da introduced a verification in blob_free that I don't understand the motive and there is no comment about it. Do you known why is it there?
best regards,
--ctarbide
In the context of git development (cf. https://lore.kernel.org/git/[email protected]), we saw that sparse (built from the tip, v0.6.4-66-g0196afe1) barfs with this declaration of regexec from glibc:
extern int regexec (const regex_t *_Restrict_ __preg,
const char *_Restrict_ __String, size_t __nmatch,
regmatch_t __pmatch[_Restrict_arr_
_REGEX_NELTS (__nmatch)],
int __eflags);
which (with macros that depend on compiler versions stripped) boils down to have either
regmatch_t __pmatch[restrict __nmatch]
or
regmatch_t __pmatch[__nmatch]
and gives
/usr/include/regex.h:682:41: error: undefined identifier '__nmatch'
/usr/include/regex.h:682:41: error: bad constant expression type
It seems that sparse can grok vla as a local variable (e.g. pre-process.c:expand() of sparse itself does have args[nargs] on stack, and make selfcheck does pass -Wno-vla), but does it understand vla as a parameter into a function? If it does not yet, any plans?
Or am I diagnosing the issue incorrectly and there is something else going on?
Thanks.
I doubt anyone pays attention to this issue tracker but just in case:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.