Snap! Websites
An Open Source CMS System in C++
CSS Preprocessor (csspp) is a scripting language that transforms advanced (extended) CSS code into a script that browsers can read.
The input to csspp can be the same as standard CSS, or it can use extensions as described below such as using basic math, embedding rules in other rules (cascading by nesting) and many other things.
The project offers a C++ library that can readily be used in your own C++ project and a command line tool.
I have go a complete csspp command line to compile your CSS or SCSS files to one of 4 available formats.
The lexer reads UTF-8 files and transform them in token.
The parser makes sure that the basic CSS 3 syntax is respected (that you have ':' and '{}' in the right place.)
The compiler transforms the tree in a set of @-keywords and rules with declarations. This includes quite a few validations already.
The compiler includes support for C/C++ like expressions. It supports logical operators (&&, ||, and ^^), relational operators (<, >, <=, >=, =, and !=), additive operators (+ and -), multiplicative operators (*, /, and %), power operators (**), unary expressions (- and +), many functions.
What is still missing is a validation process of all the declarations. There are two such validations: (a) in a specific rule can only have a certain number of declarations, for example content: is not available for a table field; and (b) each declaration only accept a certain number of data entry that have to follow a specific syntactical definition from the CSS 3 language. For example, the color: declaration expects one parameter which has to be a color or one of the few identifiers that can be used in that declaration (such as inherit.) This will be done using external files as we already have to validate various entries such as identifiers used after a colon (:) in a list of selectors. These identifiers are limited and thus we can very easily check them and make sure they are valid.
The assembler outputs a tree the compiler just worked on in one of 4 different formats (compressed, tidy, expanded, beautified.)
A CSS Preprocessor tarball can be downloaded as a tarball from SourceForge.net. You can also find the source in the snapcpp project, again on SourceForge.net:
https://github.com/m2osw/csspp
Note that to compile the source you also need the snapCMakeModules, controlled_vars, and advgetopt modules. All of those are part of the tarball distribution.
References of the csspp C++ library and command line are available online on this CSS Preprocessor website.
The scripting language supported by csspp is based on the language developed by SASS. This language allows you to include variables and nested rules making it easier to develop complex rules.
$error_color: red; div.warning { width: 75%; a { color: $error_color; } }
This definition results in the following output:
div.warning { width: 75%; } div.warning a { color: red; }
The variable was replaced by its content, and the nested rule (a) was output unnested.
These are certainly the main two features of this scripting language. There are many other features described in the documentation.
csspp is partially based on SASS. Most of the extensions of SASS will be implemented in csspp. However, the main reason for me to write csspp is to validate all the CSS rules before sending them to a browser and not so much having support for automatically generated rules and other such features of SASS.
1.0.27
1.0.26
1.0.25
1.0.24
1.0.23
1.0.22
1.0.21
1.0.20
1.0.19
1.0.18
1.0.17
1.0.16
1.0.15
1.0.14
1.0.13
Snap! Websites
An Open Source CMS System in C++