radare / spp

simple preprocessor
MIT License
60 stars 11 forks source link

Cannot find documentation #27

Open rstemmer opened 4 years ago

rstemmer commented 4 years ago

Hello,

I got to this project via https://suckless.org/other_projects/ spp claims to be language agnostic which makes it very interesting.

Problem

Sadly I cannot find any documentation of its syntax and commands.

Furthermore there are no details of what can be configured in the conf.h file. And it is not clear what HAVE_SYSTEM and HAVE_FORK actually do. In fact, the README.md raises more questions than it helps me figuring out how to use spp and where its strengths are.

From issue #22 I learned there is a special string <{. Is it possible to replace this string by a "comment-starting character" of other languages. For example % to use this pre-processor in context of LaTeX files?

Solution

I'd be cool when you provide a link to the documentation in the README, if there is an online documentation. If there is only an offline documentation, pushing it into the git (a doc/ directory) would be OK as well.

kind regards, Ralf

radare commented 4 years ago

HAVE_SYSTEM and HAVE_FORK are used to specify if the target build you are going to compile have support for the system() and fork() posix primitives.

The <{ is just one of the tokens, each backend specifies a different one, for example the CPP backend uses the# and '\nas tokens. See the last 10 lines of any of the files under thep` directory. You can create your own backend in there if you want.

There's no documentation so i can't provide a link to it. I can just write down some stuff for it indeed, but i thought the code was self explanatory. Also this engine is pretty simple and could be probably interesting to reimplement it in other languages for other purposes, or provide bindings for it.

I chose the <{ }> because its a token not used by any other programming language or preprocessor, so it shouldn't be conflicting.

rstemmer commented 4 years ago

Thank you very much.

I don't agree that this tool is simple and easy to extend. Why .multiline in spp.h is NULL and not false got only clear after looking at cpp.h. Looking at p/cpp.h, I wonder what valid entries state in the callback function can have, and what exactly its member variables mean. For example https://github.com/radare/spp/blob/master/p/cpp.h#L118 is impossible to understand without any documentation.

Anyway, even if this is not a "suckless" application (is it even possible to write suckless software?), this is a cool approach for a pre-processor.

Kind regards, Ralf

trufae commented 4 years ago

I had a look at the code recently and fixed a couple of bugs, but this project needs a lot more love and proper thread-safe api to be reused as a library. Suckless is hard to achieve, and this program was designed with suckless in mind but evolved badly.

I will eventually find time to improve it and make it cleaner and add a testsuite. Would you be interested on helping on this?

multiline is a string representing which is the char used as a line separator, not a boolean, use git grep multiline and you'll see