https://github.com/yaitskov/css-parser
Modern CSS parser in pure Haskell built on Alex+Happy stack
https://github.com/yaitskov/css-parser
alex css happy parser
Last synced: about 7 hours ago
JSON representation
Modern CSS parser in pure Haskell built on Alex+Happy stack
- Host: GitHub
- URL: https://github.com/yaitskov/css-parser
- Owner: yaitskov
- License: other
- Created: 2026-04-19T08:52:45.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2026-05-20T11:34:55.000Z (about 1 month ago)
- Last Synced: 2026-05-20T15:52:39.960Z (about 1 month ago)
- Topics: alex, css, happy, parser
- Language: Haskell
- Homepage:
- Size: 772 KB
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# css-parser
This is a modern CSS parser and printer written in pure Haskell with Alex/Happy stack.
CSS libraries test set includes: bootstrap, carbon, patternfly, uikit, primer, uswds, etc.
css-parser is based on [css-selectors](https://hackage.haskell.org/package/css-selectors).
The work is started to provide info about style sheets structure to
[miso-css](https://github.com/yaitskov/miso-css) library.
## Dev
``` shell
$ nix develop
$ emacs src/CssParser.hs &
$ cabal test
$ cabal repl
ghci> import CssParser
ghci> parseCss "p {x: 1px;}"
CssFile {rules = [CssRule (Selector Nothing (TagSelector {tagNs = NoBar, tagName = TagName "p", tagSubSelectors = []}) [] :| []) [CssLeafRule (KnownDescriptor XT) (PropVals (IntVal (TypedNum "1" Px) :| []) Nothing)]]}
```
``` shell
nix build
./result file.css
./result < file.css
```
### Integration tests
``` shell
cd itest
nix develop
intest
```
Links to successfully parsed CSS files are stored in `.css-hashes`
folder to exclude them from consequent `intest` reruns.