The Simple API for CSS

The SAC api is event driven.
That is, during the parsing, the parser notifies the application whenever it encounters some CSS constructions.

For example, the parser notifies the application at the begining and at the end of a stylesheet, at the beginning and at the end of a ruleset, when it encounters properties etc ...

But how is the notification done basically ?
Before the parsing, the application registers a set of callback functions into the parser. We call this set of callback functions a "handler". To notify the application, the parser calls certain callback functions of the handler whenever it encounters certain CSS language constructions.

For example, the callback function named "start_document" is called by the parser at the beginning of the CSS document and the callback function named "end_document" is called by the parser at the end of the CSS document.

An asynchronous programming model
If the application does not register any handler callback, the parser just quietly parses the CSS document and nothing happens from an application standpoint.

On the other hand, if the application wants some actions to be taken during the parsing, it has to register callback functions that perform the task wanted. The art of using the SAC api resides in knowing how to handle such an asynchronous programming model.

Some code examples