What is a good C/C++ CSS parser?
12,571
Solution 1
libcss seems also a common google hit and it looks good
http://www.netsurf-browser.org/projects/libcss/
Solution 2
I googled for:
"CSS Parser" C++
The first result is http://sourceforge.net/projects/htmlcxx. It's a CSS/HTML API for C++.
Solution 3
A pretty good bet would be to read through the Mozilla or Safari code-base. If you need something a little more accessible for another program, there's an ANTLR grammar (which you can use to create C++ code) at http://www.antlr3.org/grammar/1214945003224/csst3.g. The W3 validator is located at http://dev.w3.org/cvsweb/2002/css-validator/, but it is Java.
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
What is a good C/C++ CSS parser? All that I can find is CSSTidy, and it seems to be more of an application than a parsing library.
-
Admin over 11 years@Daij-Djan: because you can compile a parser out of it...
-
Daij-Djan over 11 yearsyes, so it isnt a parser and the post doesnt say how it can be used
-
Sean about 11 years@Daij-Djan: Wow, do you always need your hand held through everything? 4 years late to the party. It's a parser generator. Most parsers are built from parser generators. ANTLR C distribution is located here: antlr3.org/download/C and the documentation is here: antlr.org/wiki/display/ANTLR3/ANTLR+v3+documentation
-
Daij-Djan about 11 years@sean when someone asks for a car, I dont give him a blueprint to a car either. I now very well what is and how it works! I even built a few (simple ones) a few years back for educational purposes. sorry If my comment upset you / was too short. It was meant to be bit provocative -- but not personal of course (took back my vote)
-
Sean about 11 yearsThis is programming, not car shopping. If you ask for a program and get the source code, do you complain? Your first question was perfectly valid. Your second comment was obnoxious and unproductive. A quick Google search answers your concern.
-
Ali Gangji over 10 yearsThis is a CSS selector engine, NOT a CSS parser
-
Lothar over 9 yearsParser generators should be forbidden in 99%. THey are generating terrible code, are not in any way more maintainable then manual code and error handling usually sucks terrible. With something simple as CSS you dont want an output of ANTLR or bison
-
Sean over 9 years@Lothar can you give some examples of bad code generated by ANTLR and Bison? The code tends to be pretty hard to decipher, but the point is that you don't need to.
-
Sean over 9 yearsMeant to add this on the last comment. Didn't realize enter would submit. My experience is that the error handling is as good as the programmer makes it. For most cases the bit of overhead the parser generator adds is well worth it for the reduced development time. For someone who doesn't write parsers for a living, having a framework is a great boon. Parsing libraries can help just as well. I don't have any experience with those outside of Haskell, though.
-
Lothar over 9 yearsI can only ask if you have ever written a recursive descent parser by hand you know that the benefit of full control outweight the use of a generator a lot. I havent used Bison for more then a decade but i have witten dozens of parsers by hand. I here share the same opinion as Walter Bright who wrote the Zortec C++ compiler with an RDP.