[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Reusing KHTMLs CSS parser for a KDevelop language plugin
From:       Aleix Pol <aleixpol () kde ! org>
Date:       2009-10-21 19:51:08
Message-ID: 757d9a550910211251x3a10fd73s933ae44693d5476f () mail ! gmail ! com
[Download RAW message or body]

On Wed, Oct 21, 2009 at 8:11 PM, Milian Wolff <mail@milianw.de> wrote:

> Hello!
>
> Sooner or later I want to start on a language plugin to add CSS support to
> KDevelop (and eventually Quanta).
>
> For that I need a tokenizer and a parser. So far, each language plugin in
> KDevelop uses an AST and the Visitor concept to build the DUChain. As I've
> never used Flex myself, and am by far no expert in parsers, does the CSS
> parser support the Visitor concept?
>
> Nevertheless, I'd like to at least reuse the tokenizer from kdelibs and
> would
> write a grammar for Kdevelop-pg-qt to get a parser with an AST.
>
> I had a quick look at kdelibs/khtml/css and I see that neither the parser,
> nor
> the tokenizer gets installed. Of course, this makes sense if noone uses it
> outside of KHTML. Could this be changed? Or would those classes then have
> to
> stay BC and this is not possible/wanted for such internal classes?
>
>
> Alternatively to the above, are there maybe KHTML APIs I can use that give
> me
> a low-level analysis of a given CSS file? I'd need e.g. a list of rule
> definitions, imports, charset statements, together with line numbers where
> they
> occur. That should actually be enough to build a DUChain.
>
> Note that most of the above could be applied to other languages as well,
> most
> notably JavaScript/ECMA Script and XML/HTML/XHTML.
>
> Thanks and have a nice day
> --
> Milian Wolff
> mail@milianw.de
> http://milianw.de
>

Not as far as I know, I needed a CSS parser for a project I've been working
on, and the only solution I got was to access the CSS through the DOM. My
solution was to use libcroco (because I didn't have the time to implement
the CSS parser). libcroco using the SAC parser (like SAX but for CSS) is
quite light so it would make sense to be used.wa

A Qt CSS parser would be needed though, IMO, so if you decide to do it, I
don't think you're going to lose your time. It's not a very complicated
language anyway. (as a language, there are a lot of semantics created, of
course)

Take care,
Aleix

[Attachment #3 (text/html)]

<div class="gmail_quote">On Wed, Oct 21, 2009 at 8:11 PM, Milian Wolff <span \
dir="ltr">&lt;<a href="mailto:mail@milianw.de">mail@milianw.de</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hello!<br>
<br>
Sooner or later I want to start on a language plugin to add CSS support to<br>
KDevelop (and eventually Quanta).<br>
<br>
For that I need a tokenizer and a parser. So far, each language plugin in<br>
KDevelop uses an AST and the Visitor concept to build the DUChain. As I&#39;ve<br>
never used Flex myself, and am by far no expert in parsers, does the CSS<br>
parser support the Visitor concept?<br>
<br>
Nevertheless, I&#39;d like to at least reuse the tokenizer from kdelibs and would<br>
write a grammar for Kdevelop-pg-qt to get a parser with an AST.<br>
<br>
I had a quick look at kdelibs/khtml/css and I see that neither the parser, nor<br>
the tokenizer gets installed. Of course, this makes sense if noone uses it<br>
outside of KHTML. Could this be changed? Or would those classes then have to<br>
stay BC and this is not possible/wanted for such internal classes?<br>
<br>
<br>
Alternatively to the above, are there maybe KHTML APIs I can use that give me<br>
a low-level analysis of a given CSS file? I&#39;d need e.g. a list of rule<br>
definitions, imports, charset statements, together with line numbers where they<br>
occur. That should actually be enough to build a DUChain.<br>
<br>
Note that most of the above could be applied to other languages as well, most<br>
notably JavaScript/ECMA Script and XML/HTML/XHTML.<br>
<br>
Thanks and have a nice day<br>
<font color="#888888">--<br>
Milian Wolff<br>
<a href="mailto:mail@milianw.de">mail@milianw.de</a><br>
<a href="http://milianw.de" target="_blank">http://milianw.de</a><br>
</font></blockquote></div><br>Not as far as I know, I needed a CSS parser for a \
project I&#39;ve been working on, and the only solution I got was to access the CSS
through the DOM. My solution was to use libcroco (because I didn&#39;t have
the time to implement the CSS parser). libcroco using the SAC parser (like SAX but \
for CSS) is quite light so it would make sense to be used.wa<br><br>A Qt CSS parser \
would be needed though, IMO, so if you decide to do it, I don&#39;t think you&#39;re \
going to lose your time. It&#39;s not a very complicated language anyway. (as a \
language, there are a lot of semantics created, of course)<br> <br>Take \
care,<br>Aleix<br>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic