-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathREADME
31 lines (23 loc) · 1010 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
This is a parser for cascading style sheets. The grammar rules and actions are are stated in css.peg.
That is converted into parser.lisp using metapeg[2].
This is an ASDF system. In fact you must load it that way.
CL-USER> (in-package "CSS-PARSER")
#<Package "CSS-PARSER">
CSS-PARSER> (parse-string "DIV.example>LI{color:#333}")
(STYLESHEET (CSS-RULE (CHILD (PATH (ELEMENT "DIV") (CLASS "example")) (ELEMENT "LI")) -> ("color" (COLOR "333"))))
NIL
CSS-PARSER>
If you load fiveAM[3] prior to loading this then a bit-o-testing code will be included; which you can
run as so:
CSS-PARSER> (run! 'css-parser)
......................
Did 22 checks.
Pass: 22 (100%)
Skip: 0 ( 0%)
Fail: 0 ( 0%)
NIL
CSS-PARSER>
Those tests are in tests.lisp and provide examples.
[1] A PEG parser is a recursive decent parser with memoization mixed in so the performance
remains linear.
[2] See <http://www.cliki.net/metapeg>, though I'm actually using <http://github.com/bhyde/metapeg>