Studying Papyrix's CSS engine... Its built around a mapping from strings to "styles". Where a style consists of several properties describing the font, whitespace, & layout algorithm alongside bitflags for which of these are populated. Using another struct to associate units to length values.
The CSS parser has utils for trimming surrounding whitespace, converting text to lowerspace, & splitting text by whitespace.
As for the parser itself...
1/?
To parse some CSS Papyrix opens the file, clears some vars, loops the file with a pushback buffer, flushes buffers, validates performance limits, & cleans up. For each char it checks for a comment-start, skips all chars within comment as it looks for the comment-end, ignores returns, if it isn't in a rule checks if its in an at-rule & thus should skip balanced braces or until ";" before checking for "@" or "{" or performance limits. Within a style-rule it lexes strings & balances braces.
2/?