Tiny Css Parser
A very small css parser.
Consists of a lazy tokenizer, a lazy parser and an incremental tree builder. Both the tokenizer as well as the parser produce a stream of tokens.
The parser inserts properly balanced start and end tokens into the stream, effectively producing a traversal of the full parse tree. This stream can be fed to the tree builder to incrementally build an object tree from the stream.
Example
To parse a stylesheet into an object tree:
var css = var tree = cssconsole
To lazily parse and traverse a stylesheet:
var stream = css for var token of stream console
It is possible to query the stream for state info and source position, as follows:
var stream = css for var token of stream console
API
tokenize (string)
(generator function)parse (string)
(generator function)parseTree (string)
(function)tokens
(object/ dictionary)